daanzii Posted September 10, 2011 Share Posted September 10, 2011 hey, im looking for a quick HTML/PHP game that involves guessing a 4 digit combination 0-9 from a drop-down menu (each different drop-down boxes for each of the 4 numbers) also with a go button underneath, once the right passcode is selected (eg: 6830) hit go and you get redirected to a new page? but if its wrong it will say at the bottom Incorrect, also make it so no-one can find out the passcode by lurking around in the source code etc Can anyone find me something like this or code me one up if thats not too much trouble? kind of like the picture below? Quote Link to comment Share on other sites More sharing options...
US Vice Posted September 10, 2011 Share Posted September 10, 2011 (edited) I put this together quickly for you. <?php $code = "1034"; $first = $_POST['fdigit']; $second = $_POST['sdigit']; $third = $_POST['tdigit']; $fourth = $_POST['ldigit']; if($_POST['answer'] && $code == "$first$second$third$fourth"){ $output='Correct! You will now be redirected! <META HTTP-EQUIV="Refresh" CONTENT="0; URL=REDIRECT.php">'; }elseif($_POST['answer'] && $code != "$first$second$third$fourth"){ $output="Incorrect passcode, please try again."; } ?> <!DOCTYPE html> <html> <head> <title>Guess the code!</title> </head> <body> <div style="font-size:20px;">Guess the passcode!</div> <?php if($output != ""){ ?><div style="font-size:18px;"><?php echo"$output"; ?></div> <?php } ?> <form action="" method="POST"> <div style="font-size:16px;padding-top:20px;"><select name="fdigit"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select> <select name="sdigit"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select> <select name="tdigit"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select> <select name="ldigit"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></div> <div style="padding-left:55px;padding-top:60px;"><input type="submit" name="answer" value="Go" /></div> </form> </body> </html> Edited September 10, 2011 by US Vice Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.