You are on page 1of 12

PirMehr Ali Shah

Arid Agriculture University, Rawalpindi


Office of the controller of Examinations
Final Exam (Theory)/ Spring 2021 (Paper Duration 12 hours)
To be filled by Teacher

Course No.: ….CS-566……………Course Title: …………….Web Technologies……………………………………………


Total Marks: ……20……………………………Date of Exam: ……09-07-2021……….………....................................
Degree: ………..BSIT……………………….Semester: ……4…………………… Section: ……….…….…………………………
Marks
Q.No. 1 2 3 4 5 6 7 8 9 10 Obtained/
TotalMarks
Marks
Obtaine
d
Total Marks in Words:
Name of the teacher:
Who taught the course:Signature of teacher / Examiner:

To be filled by Student

Registration No.: 19 arid 5281…… Name: adnan waheed…………………..

Answer the following questions.

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);

//~ echo “<pre>”;


//~ print_r($arr);

//~ print_r($arr2);

// Find the longest string

$max = max(array(strlen($str), strlen($str2)));

$result = ”;

for($i = 0; $i < $max; $i++){

// Check if array key exists. If so, add it to result

if (array_key_exists($i, $arr)){

$result .= $arr[$i];

if (array_key_exists($i, $arr2)){

$result .= $arr2[$i];

echo $result; //tteesstt2

?>

output:
question#4
</head>

<body>

<div>

<h1>Enter data for Student</h1>

<form method="post">

Name:<br />

<input type="text" name="name"/><br />

city:<br />

<input type="text" name="city"/><br />

mobile no:<br />

<input type="text" name="mobile "/><br />

Roll number:<br />


<input type="text" name="rno"/>

<br><br>

<input type="submit" name="OK" />

</form>

<?php

$con=mysqli_connect("localhost","root","","student");

if(isset($_POST['OK'])){

$p =$_POST['name'];

$f =$_POST['rno'];

$sql=mysqli_query($con,"INSERT INTO students (name,rno) VALUES ('$p','$f')");

?>

</div>

</body>

</html>

output

You might also like