Create a webpage in PHP to find a person is adult or not|EasyCoding45

 In this Tutorial, we are going to learn how we can Create a webpage in PHP to find a person is adult or not.

Program :--

<html>

<head><center>

<table border=1 cellspadding=0 cellspacing=0>

<form method=get action="">

<tr><th colspan=2>Validating Age</th></tr>

<tr><th>Enter Name :</th><td><input type=text name=nm></td><br></tr>

<tr><th>Enter Age :</th><td><input type=text name=age></td><br></tr>

<tr><th colspan=2><input type=submit value=validate></th></tr><br>

</form>

</table>

</center>

</head>

</html>


<?php


$name=$_GET['nm'];

$age=$_GET['age'];


if(isset($_GET['nm']))

{

if($name=="" || $age=="")

{

echo "<script>alert('All fields are Required')</script>";

}

else

{

if($age<18)

{

echo "<script>alert('You are not Adult')</script>";

}

else

{

echo "<script>alert('You are Adult ')</script>";

}

}

}


?>

Output :--




Comments