0% found this document useful (0 votes)
6 views12 pages

PHP 6,7,8

The document provides coding examples for setting cookies, using regular expressions, and counting page views with sessions in PHP. It includes HTML forms for user input and demonstrates how to handle user sessions and cookies. Additionally, it outlines a syllabus for a dynamic web development course with various topics and resources.

Uploaded by

rajimohan2803
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views12 pages

PHP 6,7,8

The document provides coding examples for setting cookies, using regular expressions, and counting page views with sessions in PHP. It includes HTML forms for user input and demonstrates how to handle user sessions and cookies. Additionally, it outlines a syllabus for a dynamic web development course with various topics and resources.

Uploaded by

rajimohan2803
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

7.

SETTING A COOKIE AND RETRIVING THE LAST VISITED DATEOF THE WEB
PAGE

CODING:cookie_prg.php

<html>
<head>
<title>COOKIES</title>
</head>
<body>
<?php
echo "<h3>welcome</h3>";
if(isset($_COOKIE['lastvisit']) )
echo "<h3>Hi $_COOKIE[username]! welcome back!<br>You last visited
on
$_COOKIE[lastvisit]</h3>";
else{
setcookie('username', 'Buddy',time()+30*24*60*60 );
setcookie('lastvisit',date('M d,Y,h:m a'),time()+30*24*60*60);
}
?>
</body>
</html>
OUTPUT:
6.REGULAR EXPRESSION

Coding:regprg.php
<html>
<head>
<title> REGULAR EXPRESSION</title>
</head>
<body>
<center>
<h1> REGULAR EXPRESSION</h1>
<hr size=2>
<br>
<form action="" method="POST">
Enter the String of text:
<br>
<textarea rows=10 cols= 45 name="t1" ></textarea><br><br>
Enter the pattern string to search: <br><br><input type="text" name="t2"><br>
<br>
<input type="submit" name="btn1" value="MATCH">&nbsp;&nbsp;
<input type="submit" name="btn2" value="MATCH ALL">&nbsp;&nbsp;
<input type="submit" name="btn3" value="REPLACE">
</form>
</body>
</html> <?php
if(isset($_POST['t1']))
{
$str=$_POST['t1']; if(isset($_POST['btn1']))
{
$pattern =$_POST['t2']; if(preg_match($pattern,
$str))
{
echo "Match found!";
}
else
{
echo "Match not found.";
}
}
else if(isset($_POST['btn2']))
{
$pattern =$_POST['t2']; if(preg_match_all($pattern,
$str))
{
echo "Match found! ".preg_match_all($pattern,$str);
}
else
{
echo "Match not found. ".preg_match_all($pattern,$str);
}
}
else if(isset($_POST['btn3']))
{
$pattern =$_POST['t2']; echo
preg_replace($pattern,"School",$str);
}

}
?>
INPUT:
OUTPUT:
8.PAGE VIEW COUNT USING SESSIONS

Coding:Sessionprg.php
<html>
<body bgcolor="cyan">
<center><h1><u> PAGE VIEW COUNT USING SESSIONS</u></h1></center>
<br><br> <?php
session_start(); if(isset($_SESSION['views']))
$_SESSION['views'] = $_SESSION['views']+1; else
$_SESSION['views']=1;
echo "<h2><b>views = ".$_SESSION['views']."</b></h2>";
?>
</body>
</html>
OUTPUT:
SEMESTER – 6
PART III: CORE PRACTICAL – 6 – DYNAMIC WEB
DEVELOPMENT-22BITP06
Syllabus:

Unit Course content Hours E-Contents/ E-Resources

https://www.youtube.com/
1. Create a web page using control statements 5
watch?v=oJwW6Y36s_Y

https://www.youtube.com/
2. Create a web page using looping statements 5
watch?v=4PSDW1nOe90

https://www.youtube.com/
3. Create form with necessary controls for a webpage 5
watch?v=RuUgyOjnTZo

https://www.w3schools.co
4. Write a program to implement arrays and objects 5 m/php/func_array_rand.asp

https://www.youtube.com/
5. Design a webpage using String functions 5
watch?v=2TXxgwmcm8k
https://youtu.be/h5pXmdvF
Write a simple program to execute in built regular cD4?si=tEtBBrsIDVoqwR6
6. 5
expression 0

Create a program to set cookies and display last https://www.youtube.com/


7. 5 watch?v=VmB6ZrhLAp0
date visited
https://www.youtube.com/
8. Design a webpage to implement Session 5
watch?v=PNqr0YqUEp8
Design a simple application to execute file opening and https://www.youtube.com/
9. 5
closing operations watch?v=XeMbX0ijgBc
Develop a simple application to –
https://www.youtube.com/
10. a) Insert data into database 5
b) Retrieve it from database watch?v=I2lB7fZE37g

Develop a simple web application to Update and Delete https://www.youtube.com/


11. table data from database 5 watch?v=bHFoobciCTM

Write a program to create and delete a new user in https://www.youtube.com/


12 MYSQL 5 watch?v=7xiv3tALliQ

Total 60

You might also like