Professional Documents
Culture Documents
To be filled by Student
question #1
question#2
Write PHP script for storing username and password in cookie for 15 minutes?
<!DOCTYPE html>
<?php
$cookie_username = "user";
$cookie_password = 12345;
setcookie($cookie_username , $cookie_password , time() + (60 * 15), "/");
?>
<html>
<body>
<?php
if(!isset($_COOKIE[$cookie_username ])) {
echo "Cookie named '" . $cookie_name . "' is not set!";
} else {
echo "Cookie '" . $cookie_username . "' is set!<br>";
echo "Value is: " . $_COOKIE[$cookie_username ];
}
?>
</body>
</html>
output
question#3
<?php
$str = ‘IMRAN’;
$str2 = ‘KHAN’;
$arr = str_split($str);
$arr2 = str_split($str2);
//~ print_r($arr2);
$result = ”;
if (array_key_exists($i, $arr)){
$result .= $arr[$i];
if (array_key_exists($i, $arr2)){
$result .= $arr2[$i];
?>
output:
question#4
</head>
<body>
<div>
<form method="post">
Name:<br />
city:<br />
<br><br>
</form>
<?php
$con=mysqli_connect("localhost","root","","student");
if(isset($_POST['OK'])){
$p =$_POST['name'];
$f =$_POST['rno'];
?>
</div>
</body>
</html>
output