patelp7 Posted April 18, 2007 Share Posted April 18, 2007 I have got answers stored in a table row. I have created a page where answers can be written. How do I compare the answers to the data in the table? The users needs to get 3 ot of 5 right to porgress to next phase. session_start(); require ("db.php.inc"); require ("checkvaliduserfunc.inc"); if (isset($_POST['SUBMIT'])){ extract($_POST); $error=1; //check to see if variables are set if ( (isset($ans1)) && (isset($ans2)) && (isset($ans3)) && (isset($ans4)) && (isset($ans5)) ){ //Remove leading and trailing white spaces $ans1 = trim($ans1); $ans2 = trim($ans2); $ans3 = trim($ans3); $ans4 = trim($ans4); $ans5 = trim($ans5); $query = "select * from secretquest where Admin_ID ='".$_SESSION['Admin_ID']."'"; $query_result = mysql_query($query); if (mysql_num_rows($query_result)<>1){ $errorstring = "<br>Unable to match answers in database<br>"; } else { //set flag to 0 $error = 0; $results_user = mysql_fetch_array($query_result); $_session['valid'] = "YES"; $_SESSION['Admin_ID'] = $results_user['Admin_ID']; $_SESSION['Username'] = $results_user['Username']; } } if ($error<>0){ DisplayLogForm($errorstring); }else{ DisplayMenu($Username, $Userlevel, ""); } }else{ DisplayLogForm($errorstring); } } else { // if user is already logged in display relevant menu $Username = $_session['Username']; $Userlevel = $_session['Userlevel']; DisplayMenu($Username, $Userlevel, ""); } Link to comment https://forums.phpfreaks.com/topic/47485-secret-questions-and-answers/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.