Write two different PHP script to demonstrate passing variables with sessions. Write PHP script to demonstrate passing variables with cookies. Write a program to keep track of how many times a visitor has loaded the page || DWPD Sem 5 Practical 18
DWPD : Practical 18-A
Write two different PHP script to demonstrate passing variables with sessions
DWPD : Practical 18-B
Write PHP script to demonstrate passing variables with cookies
DWPD : Practical 18-C
Write a program to keep track of how many times a visitor has loaded the page.
<html>
<head>
<title>Session Demo</title>
</head>
<form method="post" action="retrive.php">
Enter Your name : <input type="text" name="fname">
<input type="submit" name="submit" value="Create session">
</form>
</html>
Output :
<?php
session_start();
if(isset($_POST['submit']))
{
$sr=$_POST['fname'];
$_SESSION['sr']=$sr;
session_start();
echo "Your name is : ".$_SESSION['sr'];
}
?>
Output :
DWPD : Practical 18-B
Write PHP script to demonstrate passing variables with cookies
<html>
<head>
<title>Cookie Demo</title>
</head>
<body>
<form method="post">
Enter Your Name :
<input type="text" name="fname" value="<?php echo $_COOKIE['myname']; ?>">
<input type="submit" value="Create Cookie" name="submit">
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$name=$_POST['fname'];
setcookie('myname',$name,time()+100,"/","",0);
echo "Your name is : ".$_COOKIE['myname'];
if(!isset($_COOKIE['myname']))
{
echo "failed to create cookie";
}
}
?>
Output :
DWPD : Practical 18-C
Write a program to keep track of how many times a visitor has loaded the page.
<?php $handle = fopen("counter.txt", "r"); if(!$handle) { echo "could not open the file" ; } else { $counter = (int ) fread($handle,20); fclose ($handle); $counter++; echo" <strong> you are visitor no ". $counter . " </strong> " ; $handle = fopen("counter.txt", "w" ); fwrite($handle,$counter); fclose($handle);
} ?>
Output :
-----------------------------------------
queries:
PHP script to print Fibonacci series
PHP script to print Fibonacci series using recursion
PHP Fibonacci series
Fibonacci series in PHP
How to print Fibonacci series in PHP
Recursion in PHP
PHP recursion
PHP tutorial
PHP programming
PHP script to print Fibonacci series
PHP script to print Fibonacci series using recursion
PHP Fibonacci series
Fibonacci series in PHP
How to print Fibonacci series in PHP
Recursion in PHP
PHP recursion
PHP tutorial
PHP programming
This comment has been removed by a blog administrator.
ReplyDelete