tabatsoy Posted March 22, 2008 Share Posted March 22, 2008 Greetings Earthlings! Please help me in my coding. Here is my code: 1. <? 2. session_start(); 3. $db = mysql_connect("localhost"); 4. mysql_select_db("examination",$db); 5. 6. if(!$_SESSION['bago'] && !$_SESSION['bago2']){ 7. echo '<br><font size = "3" color = "#000000"><strong>Invalid session! 8. <br>You cannot view this page.</font></strong><br><br>'; 9. exit; 10. } 11. ?> 12. 13. 14. <html> 15. <body> 16. <FORM name ="form1" method ="post" action ="dummy.php"> 17. <table width="800" border="0" align="center" class="underresult"> 18. <? 19. $query = "SELECT * 20. FROM mathquestions"; 21. $result = mysql_query($query); 22. for($i = 0; $i < mysql_num_rows($result); $i++){ 23. $question_number ++; 24. $question = mysql_result($result, $i, "question"); 25. $choiceA = mysql_result($result, $i, "choiceA"); 26. $choiceB = mysql_result($result, $i, "choiceB"); 27. $choiceC = mysql_result($result, $i, "choiceC"); 28. $choiceD = mysql_result($result, $i, "choiceD"); 29. $answer = mysql_result($result, $i, "answer"); 30. $selected_radio = $_POST[$question_number]; 31. if ($selected_radio == $answer) { 32. $score ++; 33. $valid = true; 34. if($valid){ 35. $result2 = mysql_query("update examinee set math = '".$score."' 36. where firstname = '".$_SESSION['bago']."'"); 37. } 38. } 39. echo '<tr> 40. <td></td>'; 41. '</tr>'; 42. echo '<tr> 43. <td> </td>'; 44. '</tr>'; 45. 46. echo '<tr> 47. <td width = "20" align = "left" valign = "top"><font class = "questions">'.$question_number.'.</span><td>'; 48. echo '<td width = "280" align = "left" valign = "top" ><font class = "questions">'.$question.'</span></td>'; 49. echo '<td width = "125" align = "left" valign = "center" > </td>'; 50. echo '<td width = "125" align = "left" valign = "center" > </td>'; 51. echo '<td width = "125"align = "left" valign = "center" > </td>'; 52. echo '<td width = "125" align = "left" valign = "center" > </td></tr>'; 53. 54. echo '<tr> 55. <td> </td>'; 56. '</tr>'; 57. 58. 59. echo '<tr> 60. <td width = "20" align = "left" valign = "top"><td>'; 61. echo '<td width = "280" align = "left" valign = "center" > </td>'; 62. echo '<td width = "125" align = "left" valign = "center" ><font class = "style1"><input name="'.$question_number.'" type="radio" value="'.$choiceA.'" />'.$choiceA.'</span></td>'; 63. echo '<td width = "125" align = "left" valign = "center" ><font class = "style1"><input name="'.$question_number.'" type="radio" value="'.$choiceB.'" />'.$choiceB.'</span></td>'; 64. echo '<td width = "125"align = "left" valign = "center" ><font class = "style1"><input name="'.$question_number.'" type="radio" value="'.$choiceC.'" />'.$choiceC.'</span></td>'; 65. echo '<td width = "125" align = "left" valign = "center" ><font class = "style1"><input name="'.$question_number.'" type="radio" value="'.$choiceD.'" />'.$choiceD.'</span></td></tr>'; 66. 67. echo '<tr> 68. <td colspan = "7" class = "exam"> 69. </td> 70. </tr>'; 71. } 72. ?> 73. 74. </table> 75. <br /><br /> 76. <table width="240" border="0" align="center" class="session"> 77. <tr> 78. <td> <Input type = "Submit" Name = "Submit" VALUE = "Submit"> 79. </tr> 80. </table> 81. <br /> 82. </FORM> 83. </body> 84. </html> 85. all i want is when i press the submit button the score will be added in the database and it will redirect me on another page. Or when i press on the submit button the score will be added in the database and a message will appear showing a message("Thank you for taking the exam"). thanks in advance please help Link to comment https://forums.phpfreaks.com/topic/97366-form-redirecting-problem/ Share on other sites More sharing options...
monkeytooth Posted March 22, 2008 Share Posted March 22, 2008 If i understand you correctly.. All you have to do is point "dummy.php" to so much as a blank page that does what you want as far as totaling a score, inserting it into a database, then jumping to another page to display it.. or, you could just have it point to a page that does it all then display's it.. but short of using a bit of ajax style coding, your not gonna get it done in a live sense via the same page, unless, you have it ultimately refresh the page with all the info, and setting a pram that defines the form as being filled out already you just want it to do its calculations and show the info and do its thing.. Link to comment https://forums.phpfreaks.com/topic/97366-form-redirecting-problem/#findComment-498259 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.