PHP Lab Manual
PHP Lab Manual
8. WRITE A PROGRAM FOR COMBINING HTML AND PHP CODE ON A SINGLE PAGE
<!doctype html>
<html>
<head>
<title>
Use a Php in Html
</title>
</head>
<body>
<h1>
<?php
echo " This is example program for combining HTML and PHP "
?>
</h1>
</body>
</html>
<?php
setcookie("user", "DNR");
?>
<html>
<body>
<?php
if(!isset($_COOKIE["user"]))
{
echo "Sorry, cookie is not found!";
}
else
{
echo "<br/>Cookie Value: " . $_COOKIE["user"];
}
?>
</body>
</html>
Department of Computer Science PHP LAB MANUAL Page 8
OUTPUT:
Firstly cookie is not set. But, if you refresh the page, you will see cookie is set now.