Jump to content

PHP age/license checker not working


seph32

Recommended Posts

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.";
            }
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.