Simple Age check Before Entering Site

Was This easy to understand

  • needed more information

    Votes: 0 0.0%
  • It was really hard to understand

    Votes: 0 0.0%

  • Total voters
    3
Status
Not open for further replies.

GarettM

Posting Freak
Aug 5, 2010
833
136
Hello Devbest I was thinking its really easy to check Your age Before u enter the site,

Writing The Code.

// Lets First Make Some Sexy HTML!
PHP:
<!html>
<head>
<title> Landing Page </title>
</head>
<body>

// ok lets Stop right there. Know we gotta check if any Form has been Submitted yet
PHP:
<?php
if (!isset($_POST['submit'])) {
?>
// this is the form will see if the submit hasnt been pushed yet
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Enter your age: <input name="age" size="2">
<input type="submit" name="submit" value="Go">
 
</form>
<?php
}//end if submited
else {
 
// display result
$age = $_POST['age'];
 
// this is a easy way of checking your age//
if($age >= 21)
{
$msg = 'Come on in, we have alcohol and music awaiting you!';
 
}
else
{
$msg = 'Sorry Your to young For this party D:';
 
// More Advance//
$msg = $age < 21 ? 'Your to young' : 'get your ass in here';
}
// that is how i do my if situations sorry :p
echo $msg;
 
 
}
?>
 

Macemore

Circumcised pineapples
Aug 26, 2011
1,681
819
PHP:
<?php
}//end if submited
else {
I'm not sure if you can end a If statement without one being there?


Other than that, it's great, thank you
 

Ept

Many men wish death upon me.
Jun 16, 2011
591
276
This is not your code, but it's good for beginners.
 
Status
Not open for further replies.

Users who are viewing this thread

Top