seph32 Posted September 10, 2012 Share Posted September 10, 2012 I am a beginner learning PHP and I'm having issues with this script. Script basicly just checks if age is 18 or up or if age is 17 or lower secondly if you filled in "yes" or "no" if you have a license. What i basically want: 18 and yes: says you are 18 and have a license 18 and no license: says you are 18 and have no license 17 and no license: says you are too young and have no license. 17 and yes: says you commited fraud cause you are 17 and have a license. form.html <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Opdracht 3</title> </head> <body> <form action="post.php" method="post" /> <label>Age</label> <input type="text" name="age" size="30" /><br/> <label>Driver license?</label> <input type="text" name="confirm" size="30" /><br/> <input type="submit" name="button" value="Stuur op" /> </body> </html> post.php <?php if (isset($_POST['button'])) { $age = $_POST["age"]; $confirm = $_POST["confirm"]; } if ($confirm = "yes" AND $age > 18) { print "You are 18 or older and you have a driver license."; } if ($confirm = "no" AND $age > 18) { print "You are 18 or older and you do not own a driver license."; } if ($confirm = "no" AND $age < 17) { print "You are 17 or younger and you do not own a driver license."; } if ($confirm = "yes" AND $age < 17) { print "You commited fraud, because you are 17 or younger and you own a driver license."; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/268242-php-agelicense-checker-not-working/ Share on other sites More sharing options...
Mahngiel Posted September 10, 2012 Share Posted September 10, 2012 it doesn't work because = is for assigning, while == and === are for comparison Quote Link to comment https://forums.phpfreaks.com/topic/268242-php-agelicense-checker-not-working/#findComment-1376864 Share on other sites More sharing options...
seph32 Posted September 10, 2012 Author Share Posted September 10, 2012 Thank you for the reply, its working now. Quote Link to comment https://forums.phpfreaks.com/topic/268242-php-agelicense-checker-not-working/#findComment-1376868 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.