Xyphon Posted July 24, 2009 Share Posted July 24, 2009 I've made a little exam for my site, and for some reason it won't work. It echos: Sorry, either you didn't answer every question, or you didn't get them all right. Try again Even though I know I did Here's the script. if(isset($_POST['Ready'])) { echo "Time for the quiz!"; echo "<br />1. How should you treat fellow members?"; echo "<br /><form method='post'>"; echo "<input type='radio' name='one' value='nice'>Be nice to them.<br />"; echo "<input type='radio' name='one' value='respect'>Treat them with respect.<br />"; echo "<input type='radio' name='one' value='you'>Treat them how you want to be treated.<br />"; echo "<input type='radio' name='one' value='all'>All of the above.</form><br />"; echo "<br />2. Which of these is NOT a rule?"; echo "<br /><form method='post'>"; echo "<input type='radio' name='two' value='flame'>No Flaming at all.<br />"; echo "<input type='radio' name='two' value='swear'>No Swearing at all.<br />"; echo "<input type='radio' name='two' value='spam'>Don't Spam.<br />"; echo "<input type='radio' name='two' value='ask'>Don't ask Xyphon to do a page.</form><br />"; echo "<br />3. Which of these IS a rule?"; echo "<br /><form method='post'>"; echo "<input type='radio' name='three' value='ad'>Don't advertise.<br />"; echo "<input type='radio' name='three' value='cheat'>You can cheat if you don't get caught.<br />"; echo "<input type='radio' name='three' value='sites'>Don't talk about other sites.<br />"; echo "<input type='radio' name='three' value='staff'>You can't be staff if you asked to be one at any time.</form><br />"; echo "<br />4. What is rule #5?"; echo "<br /><form method='post'>"; echo "<input type='radio' name='four' value='ad2'>Don't advertise.<br />"; echo "<input type='radio' name='four' value='racial'>No Racial Language<br />"; echo "<input type='radio' name='four' value='flame2'>Don't Flame.<br />"; echo "<input type='radio' name='four' value='sexual'>No Sexual Content.</form><br />"; echo "<br />5. What is rule #9?"; echo "<br /><form method='post'>"; echo "<input type='radio' name='five' value='ad3'>Don't advertise.<br />"; echo "<input type='radio' name='five' value='racial2'>No Racial Language<br />"; echo "<input type='radio' name='five' value='flame3'>Don't Flame.<br />"; echo "<input type='radio' name='five' value='sexual2'>No Sexual Content.<br />"; echo "<input type='submit' name='Submit5' value='Done'></form>"; $one= $_POST['one']; $two= $_POST['two']; $three= $_POST['three']; $four= $_POST['four']; $five= $_POST['five']; } elseif(isset($_POST['Submit5'])) { if($one=="all" && $two=="swear" && $three=="ad" && $four=="racial" && $five=="sexual2") { echo "Good job! You are now a Genin! You can now explore the game freely! Go to the <a href='index.php'>Home page</a>."; $Student="Genin"; $Genin=mysql_real_escape_string($Student); mysql_query("UPDATE users SET UserPosition='$Genin' WHERE ID='$ID'"); } else { echo "Sorry, either you didn't answer every question, or you didn't get them all right. <a href='geninexam.php'>Try again</a>."; } } Link to comment https://forums.phpfreaks.com/topic/167342-solved-php-exam-wont-work/ Share on other sites More sharing options...
lonewolf217 Posted July 24, 2009 Share Posted July 24, 2009 your form has no action, so how are you submitting it ? a copy/paste of your code displays nothing, so are you redirecting here from another page or something ? Where does $_POST['Ready'] come from? why do you have 5 different forms. why not have 1 form with 5 different fields and validate them all at the same time ? Link to comment https://forums.phpfreaks.com/topic/167342-solved-php-exam-wont-work/#findComment-882383 Share on other sites More sharing options...
Xyphon Posted July 24, 2009 Author Share Posted July 24, 2009 That's just a snipit, here's the full code: <?PHP include('Connect.php'); $ID = $_SESSION['UserID']; $ID = mysql_real_escape_string($ID); $IPResult= mysql_query("SELECT * FROM ip_banned"); if (!isset($_SESSION['UserID'])) { echo " <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"> <html lang=\"en\" xml:lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset='utf-8\" /> <title>Naruto Palace RPG</title> <link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" /> </head> <body> <div id=\"banner\"><img src=\"banner(1).png\" alt=\"Banner\"/></div> <div id=\"quicklinks\"></div> <div id=\"leftmenu\"> <ul> <li>Main <ul> <li><a href=\"index.php\">Home</a></li> <li><a href=\"login.php\">Login</a></li> <li><a href=\"register.php\">Register</a></li> <li><a href=\"termsandconditions.php\">Terms and Conditions</a></li> </ul> </li> </ul></div> <div id=\"content\">"; while($IPRows = mysql_fetch_array($IPResult)) { $IPBanned= $IPRows['IP']; $User_IP = $_SERVER['REMOTE_ADDR']; if($IPBanned == $User_IP) { echo "Sorry, you are IP banned.<br /> Please go <a href='index.php'>back</a>."; session_unset(); session_destroy(); include('bottom.php'); exit; } } } else { echo " <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"> <html lang=\"en\" xml:lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\"> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset='utf-8\" /> <title>Naruto Palace RPG</title> <link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" /> </head> <body> <div id=\"banner\"><img src=\"banner(1).png\" alt=\"Banner\"/></div> <div id=\"quicklinks\"></div> <div id=\"leftmenu\"> <ul> <li>Affiliates <ul> <li><a href=\"http://pokemonparadise.info\">Pokemon Paradise</a></li> </ul> </li> <li>Main <ul> <li><a href=\"index.php\">Home</a></li> <li><a href=\"logout.php\">Logout</a></li> <li><a href=\"rules.php\">Rules</a></li> <li><a href=\"/forum\">Forums</a></li> <li><a href=\"itempromo.php\">PROMO: " . $PromoName . "</a></li> <li><a href=\"termsandconditions.php\">Terms and Conditions</a></li> </ul> </li> <li>Clans <ul> <li><a href=\"clans.php\">Join a Clan</a></li> <li><a href=\"\">Bloodline Shop<font color=\"red\">*</font></a></li> </ul> </li> <li>Villages <ul> <li><a href=\"village.php\">Join a Village</a></li> <li><a href=\"abandon.php\">Abandon Village</a></li> <li><a href=\"\">Konoha<font color=\"red\">*</font></a></li> <li><a href=\"\">Suna<font color=\"red\">*</font></a></li> <li><a href=\"\">Kiri<font color=\"red\">*</font></a></li> <li><a href=\"\">Amega<font color=\"red\">*</font></a></li> </ul> </li> <li>Shops <ul> <li><a href=\"buytaijutsu.php\">Taijutsu Shop</a></li> <li><a href=\"buyninjutsu.php\">Ninjutsu Shop</a></li> <li><a href=\"\">Genjutsu Shop<font color=\"red\">*</font></a></li> <li><a href=\"buyweapons.php\">Weapon Shop</a></li> <li><a href=\"\">Sell Jutsus<font color=\"red\">*</font></a></li> </ul> </li> </ul> </div> <div id=\"content\">"; } while($IPRows = mysql_fetch_array($IPResult)) { $IPBanned= $IPRows['IP']; $User_IP = $_SERVER['REMOTE_ADDR']; if($IPBanned == $User_IP) { echo "Sorry, you are IP banned, you will now be logged out. Please go <a href=\"index.php\">back</a>."; include('bottom.php'); session_unset(); session_destroy(); exit; } } $BannedResult= mysql_query("SELECT * FROM users WHERE id='$ID'"); $BannedRows= mysql_fetch_array($BannedResult); $Usercheck = $BannedRows['Username']; $Usercheck = mysql_real_escape_string($Usercheck); $Passcheck = $BannedRows['Password']; $Passcheck = mysql_real_escape_string($Passcheck); $Result1 = mysql_query("SELECT * FROM users WHERE Username='$Usercheck' AND Password='$Passcheck'"); $Rows1 = mysql_fetch_array($Result1); if($BannedRows['Banned']=='Yes') { echo "Sorry, you are banned. You will now be logged out.<br /> Please go <a href=\"index.php\">back</a>."; $Result1 = mysql_query("SELECT * FROM users WHERE Username='$Usercheck' AND Password='$Passcheck'"); $Rows1 = mysql_fetch_array($Result1); include('bottom.php'); session_unset(); session_destroy(); exit; } if(!isset($_SESSION['UserID'])) { echo "Sorry, you must be logged in to view this page"; include('bottom.php'); exit; } $ID=$_SESSION['UserID']; $ID=mysql_real_escape_string($ID); $Result= mysql_query("SELECT * FROM users WHERE ID='$ID'"); $Rows= mysql_fetch_array($Result); $Rank= $Rows['UserPosition']; if($Rank !="Student") { echo "You have to be an academy student to take this exam."; include('bottom.php'); exit; } if(isset($_POST['Ready'])) { echo "Time for the quiz!"; echo "<br />1. How should you treat fellow members?"; echo "<br /><form method='post'>"; echo "<input type='radio' name='one' value='nice'>Be nice to them.<br />"; echo "<input type='radio' name='one' value='respect'>Treat them with respect.<br />"; echo "<input type='radio' name='one' value='you'>Treat them how you want to be treated.<br />"; echo "<input type='radio' name='one' value='all'>All of the above.</form><br />"; echo "<br />2. Which of these is NOT a rule?"; echo "<br /><form method='post'>"; echo "<input type='radio' name='two' value='flame'>No Flaming at all.<br />"; echo "<input type='radio' name='two' value='swear'>No Swearing at all.<br />"; echo "<input type='radio' name='two' value='spam'>Don't Spam.<br />"; echo "<input type='radio' name='two' value='ask'>Don't ask Xyphon to do a page.</form><br />"; echo "<br />3. Which of these IS a rule?"; echo "<br /><form method='post'>"; echo "<input type='radio' name='three' value='ad'>Don't advertise.<br />"; echo "<input type='radio' name='three' value='cheat'>You can cheat if you don't get caught.<br />"; echo "<input type='radio' name='three' value='sites'>Don't talk about other sites.<br />"; echo "<input type='radio' name='three' value='staff'>You can't be staff if you asked to be one at any time.</form><br />"; echo "<br />4. What is rule #5?"; echo "<br /><form method='post'>"; echo "<input type='radio' name='four' value='ad2'>Don't advertise.<br />"; echo "<input type='radio' name='four' value='racial'>No Racial Language<br />"; echo "<input type='radio' name='four' value='flame2'>Don't Flame.<br />"; echo "<input type='radio' name='four' value='sexual'>No Sexual Content.</form><br />"; echo "<br />5. What is rule #9?"; echo "<br /><form method='post'>"; echo "<input type='radio' name='five' value='ad3'>Don't advertise.<br />"; echo "<input type='radio' name='five' value='racial2'>No Racial Language<br />"; echo "<input type='radio' name='five' value='flame3'>Don't Flame.<br />"; echo "<input type='radio' name='five' value='sexual2'>No Sexual Content.<br />"; echo "<input type='submit' name='Submit5' value='Done'></form>"; $one= $_POST['one']; $two= $_POST['two']; $three= $_POST['three']; $four= $_POST['four']; $five= $_POST['five']; } elseif(isset($_POST['Submit5'])) { if($one=="all" && $two=="swear" && $three=="ad" && $four=="racial" && $five=="sexual2") { echo "Good job! You are now a Genin! You can now explore the game freely! Go to the <a href='index.php'>Home page</a>."; $Student="Genin"; $Genin=mysql_real_escape_string($Student); mysql_query("UPDATE users SET UserPosition='$Genin' WHERE ID='$ID'"); } else { echo "Sorry, either you didn't answer every question, or you didn't get them all right. <a href='geninexam.php'>Try again</a>."; } } else { echo "Hello, new user. This is the genin exam. I will go over the rules of the site, and then you will be quizzed on them. If you get them all right, you can become a genin and play this game. Let's begin."; echo "<br />"; echo "<br /><div class='table_replace'>Rule #1: Be nice - Treat your fellow members with respect. Treat them how you want to be treated (unless you want to be treated like crap)</div>"; echo "<div class='table_replacerules'>Rule #2: Don't Flame - Flaming is when you make fun of someone. If you have a problem with them, tell a staff member.</div>"; echo "<div class='table_replacerules'>Rule #3: Don't Spam - <b>S</b>tupid <b>P</b>ointless <b>A</b>nnoying <b>M</b>essages. Do not post these!!!</div>"; echo "<div class='table_replacerules'>Rule #4: Don't Cheat - Don't be a glitch abuser. If you find a glitch, report it. If you are caught abusing a glitch/cheating, you will be banned.</div>"; echo "<div class='table_replacerules'>Rule #5: No Racial Language - Don't say anything offensive to races, whether you are part of that race or not.</div>"; echo "<div class='table_replacerules'>Rule #6: Don't swear too much - We don't have to see you saying shit every second word. You are allowed to say it, just not too much. Although the 'F' word or anything as vulgar is not allowed.</div>"; echo "<div class='table_replacerules'>Rule #7: Don't Advertise - We don't need you drawing members away from our site... We need our members!!!!</div>"; echo "<div class='table_replacerules'>Rule #8: Don't Ask to be a staff! - Asking to be a staff member will lower your chances of ever being one. Don't ask!</div>"; echo "<div class='table_replacerules'>Rule #9: No Sexual Content - Don't put porn or anything on here. Also, do not talk about anything sexual.</div>"; echo "<div class='table_replacerules'>Rule #10: Don't Ask/Tell Xyphon to do a page - Xyphon will do the links on the site when he wants to do them, he doesn't want people bugging him about it.</div>"; echo "<br /><br />"; echo "<form method='POST'><input type='Submit' name='Ready' value='Ready to take the exam'></form>"; } include('bottom.php'); ?> And I don't even know why, it just ended up that way lol Link to comment https://forums.phpfreaks.com/topic/167342-solved-php-exam-wont-work/#findComment-882384 Share on other sites More sharing options...
Xyphon Posted July 24, 2009 Author Share Posted July 24, 2009 Hey, nevermind, I figured it out myself. Topic solved. Link to comment https://forums.phpfreaks.com/topic/167342-solved-php-exam-wont-work/#findComment-882390 Share on other sites More sharing options...
lonewolf217 Posted July 24, 2009 Share Posted July 24, 2009 your problem is that you have 5 forms, but only 1 submit button, so the verification check fails as it only receives the data from form 5 Link to comment https://forums.phpfreaks.com/topic/167342-solved-php-exam-wont-work/#findComment-882392 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.