Write a PHP program that takes name and age from an HTML page. If the age is less than 18, it should send a page with “hello ,and u are not authorized to visit this site” otherwise it should send “welcome to this site” message where name should be replaced with the entered name otherwise it should send welcome to the site message.||EasyCoding45
In This Tutorial we are going to learn how we can Write a PHP program that takes name and age from an HTML page. and If the age is less than
18, then it should send a page with “hello
Program 1(HTML) ::--(Accept Data from User )
<html>
<head>
<title>User Information</title>
<table border=1>
<form method=post action="A3.php">
<tr><th>Enter User Name :</th><td><input type=text name=t1></td></br>
<tr><th>Enter User Age :</th><td><input type=text name=t2></td></br>
</table>
<input type=submit value=submit>
</form>
</center>
</head>
</html>
Output (HTML)::--
Program (PHP)::--
<?php
$name=$_POST['t1'];
$age=$_POST['t2'];
if($age<18)
{
echo "Hello <b>$name</b> and u are not Authorized to visit this site ";
}
else
echo "Welcome <b>$name</b> to this Site ";
?>
Output (PHP)::--
Comments
Post a Comment