Jump to content

Maluen

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by Maluen

  1. Add a new input element to keep track of question ID, then handle the submit on top of page, escaping the id to avoid sql injections: if (isset($_POST['submit'])) { $QuestionID = $_POST['questionid']; mysql_query("UPDATE fastquestion SET Answered='no' WHERE questionID='".mysql_real_escape_string($QuestionID)."'") or die(mysql_error()); echo "done"; } $ophalen = mysql_query("SELECT * FROM fastquestion") or die(mysql_error()); while ($gegevens = mysql_fetch_array($ophalen)) { echo "type of the question: ".$gegevens['typequestion']; echo '<br />'; echo "the Question: ".$gegevens['Question']; echo '<br />'; echo "in game name or E-mail: ".$gegevens['ingamenameEmail']; echo '<br />'; echo "already answered: ".$gegevens['Answered']; echo '<br />'; echo "<form name='form1' method='post' action=".$_SERVER['PHP_SELF'].">"; echo "Answered a question? check the question as answered then:"; $QuestionID=$gegevens['questionID']; echo '<br />'; echo '<input name="questionid" value="'.$QuestionID.'" />'; echo '<input value="answered" name="submit" type="submit" />'; echo '</form>'; echo '<hr />'; } In this way only one form is handled (the user can't submit more than one form at once) and the select sql query gets the updated value. Also note that the html input element must be closed with " />"
×
×
  • Create New...