-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8af320
commit 47ffb7b
Showing
82 changed files
with
2,946 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
/*Write a script to keep track of number of times the web page has been accessed using session. | ||
*/ | ||
if(isset($_COOKIE['accesses'])) | ||
$cnt = $_COOKIE['accesses']; | ||
else | ||
$cnt = 0 ; | ||
setcookie('accesses', ++$cnt); | ||
echo "You have visited this page $cnt times "; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
<html> | ||
<! | ||
Create a login form with a username and password. Once the user logs in, the second form | ||
should be displayed to accept user details (name, city, phoneno). If the user doesn’t enter | ||
information within a specified time limit, expire his session and give a warning otherwise | ||
Display Details using sessions. | ||
!> | ||
|
||
<form method="POST" action="login.php" > | ||
<p>User Name: <input type="text" name="user"><br> | ||
<p>Password :<input type="password"><br><br> | ||
<input type="submit" value="Login"><br> | ||
</form> | ||
</html> | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<html> | ||
<body> | ||
<form action="01.php" method="post"> | ||
<h2>Enter Students information :</h2> | ||
<table> | ||
<tr><td>Name : </td><td><input type="text" name="name"></td><tr> | ||
<tr><td>Address : </td><td><input type="text" name="addr"></td></tr> | ||
<tr><td>Class : </td><td><input type="text" name="class"></td></tr> | ||
<tr><td></td><td><input type="submit" value=Next></td></tr> | ||
</table> | ||
</form> | ||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<html> | ||
<body> | ||
<form action="131.php" method="get"> | ||
<center> | ||
<b>Select font style :</b><input type=text name=s1> <br> | ||
<b>Enter font size : </b><input type=text name=s><br> | ||
<b>Enter font color : </b><input type=text name=c><br> | ||
<b>Enter background color :</b> <input type=text name=b><br> | ||
<input type=submit value="Next"> | ||
</center> | ||
</form> | ||
</body> | ||
</html> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
A1. A web application that lists all cookies stored in the browser on clicking “list cookies” button, | ||
add cookies if necessary. | ||
|
||
<?php | ||
|
||
if(isset($_COOKIE['accesses'])) | ||
$cnt = $_COOKIE['accesses']; | ||
else | ||
$cnt = 0 ; | ||
setcookie('accesses', ++$cnt); | ||
echo "You have visited this page $cnt times "; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
A2. Write a PHP program to store current date-time in a COOKIE and display the ‘Last visited on’ | ||
date-time on the web page upon reopening of the same page. | ||
|
||
<?php | ||
if(isset($_COOKIE['datee'])) | ||
{ | ||
$cookieData = $_COOKIE['datee']; | ||
} | ||
$today = getdate(); | ||
$d = $today['mday']; | ||
$m = $today['mon']; | ||
$y = $today['year']; | ||
$datestring = "$d - $m - $y"; | ||
setcookie("datee", $datestring); | ||
echo "Last visited on date-time:- $cookieData"; | ||
?> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
A4. Create a login form with a username and password. Once the user logs in, the second form | ||
should be displayed to accept user details (name, city, phoneno). If the user doesn’t enter | ||
information within a specified time limit, expire his session and give a warning otherwise | ||
Display Details using sessions. | ||
<html> | ||
<body> | ||
<form action="ass6a_4.php" method=get> | ||
<input type='hidden' name='etime' value="<?php echo $t?>"> | ||
Enter Name : <input type=textbox name=uname> <br> | ||
Enter City : <input type=textbox name=city><br> | ||
Enter Phone No :<input type=textbox name=pno><br> | ||
<input type=submit name=submit value=DISPLAY> | ||
</form> | ||
</body> | ||
</html> | ||
|
||
|
||
<?php | ||
session_start(); | ||
$t=date("1,d-m-y h:i:s",time()+20); | ||
|
||
$_SESSION['etime']=$t; | ||
if(isset($_REQUEST['name'])) | ||
//if(isset $_REQUEST['pwd'])) | ||
{ | ||
echo "Invalid Username Or Password"; | ||
} | ||
?> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
$pno=$_GET['pno']; | ||
$name=$_GET['name']; | ||
$premium=$_GET['premium']; | ||
if(isset($_COOKIE['ename'])&&isset($_COOKIE['address'])&&isset($_COOKIE['mobile'])) | ||
{ | ||
echo"<br><b>Employee Details </b><br>"; | ||
echo"Employee Name : ".$_COOKIE['ename']." <br>"; | ||
echo"Employee Address :".$_COOKIE['address']."<br>"; | ||
echo"Mobile No. : ".$_COOKIE['mobile']."<br>"; | ||
echo"<br><b>LIC Policy Details</b><br>"; | ||
echo"Policy No. : $pno<br>"; | ||
echo"Policy Name : $name<br>"; | ||
echo"Premium : $premium"; | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Q..Define an interface which has methods area( ), volume( ). Define constant PI. Create a class | ||
cylinder which implements this interface and calculate area and volume. | ||
|
||
|
||
|
||
<?php | ||
interface Cyl | ||
{ | ||
function area(); | ||
function volume(); | ||
} | ||
class Cylinder implements Cyl | ||
{ | ||
public $PI=3.14; | ||
public $a; | ||
public $r; | ||
public $h; | ||
function __construct($r,$h) | ||
{ | ||
$this->r=$r; | ||
$this->h=$h; | ||
} | ||
function area() | ||
{ | ||
$this->a=2*$this->PI*($this->h*$this->r); | ||
echo"Area of Cylinder= ".$this->a."<br>"; | ||
} | ||
function volume() | ||
{ | ||
$this->a=$this->PI*$this->r*$this->r*$this->h; | ||
echo"Volume of Cylinder= ".$this->a."<br>"; | ||
} | ||
} | ||
$c=new Cylinder(10,7); | ||
$c->area(); | ||
$c->volume(); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
Q..Write a PHP script to demonstrate the introspection for examining class .(use function | ||
et_declared_classes() ,get_class_methods() and get_class_vars()). | ||
|
||
|
||
|
||
|
||
<?php | ||
class intro | ||
{ | ||
var $i; | ||
function f1() | ||
{ | ||
|
||
} | ||
function f2() | ||
{ | ||
|
||
} | ||
} | ||
class intro_1 extends intro | ||
{ | ||
var $j,$k; | ||
function f3() | ||
{ | ||
|
||
} | ||
function f4() | ||
{ | ||
|
||
} | ||
} | ||
$ob=new intro_1(); | ||
echo class_exists('intro'); | ||
var_dump(get_declared_classes()); | ||
var_dump(get_class_methods('intro_1')); | ||
var_dump(get_class_methods('Exception')); | ||
var_dump(get_class_vars('intro_1')); | ||
var_dump(get_parent_class('intro_1')); | ||
var_dump(get_object_vars($ob)); | ||
?> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Q...Write PHP script to demonstrate the concept of introspection for examining object. | ||
|
||
|
||
|
||
<?php | ||
class introspection | ||
{ | ||
var $i; | ||
function f1() | ||
{ | ||
|
||
} | ||
function f2() | ||
{ | ||
|
||
} | ||
} | ||
class introspection1 extends introspection | ||
{ | ||
var $j,$k; | ||
function f3() | ||
{ | ||
|
||
} | ||
function f4() | ||
{ | ||
|
||
} | ||
} | ||
$ob=new introspection1(); | ||
if(is_object($ob)) | ||
{ | ||
echo get_class($ob); | ||
} | ||
if(method_exists($ob,'f4')) | ||
{ | ||
echo "method f4 exists"; | ||
} | ||
var_dump(get_object_vars($ob)); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
<?php | ||
/*b1.Create class rectangle and derive a class square from class Rectangle. Create another class | ||
circle. Create an interface with only one method called area(). Implement this interface in all | ||
the classes. Include appropriate data members and constructors in all classes. W rite a program | ||
to accept details of a square, circle and rectangle and display the area.*/ | ||
interfce Car | ||
{ | ||
public function setmodel($name); | ||
public function getmodel(); | ||
} | ||
class miniCar implements Car | ||
{ | ||
private $model; | ||
|
||
public function setModel($name) | ||
{ | ||
$this -> model = $name; | ||
} | ||
|
||
public function getModel() | ||
{ | ||
return $this -> model; | ||
} | ||
} | ||
interface Vehicle | ||
{ | ||
public function setHasWheels($bool); | ||
|
||
public function getHasWheels(); | ||
} | ||
|
||
class miniCar implements Car, Vehicle | ||
{ | ||
private $model; | ||
private $hasWheels; | ||
|
||
public function setModel($name) | ||
{ | ||
$this -> model = $name; | ||
} | ||
|
||
public function getModel() | ||
{ | ||
return $this -> model; | ||
} | ||
|
||
public function setHasWheels($bool) | ||
{ | ||
$this -> hasWheels = $bool; | ||
} | ||
|
||
public function getHasWheels() | ||
{ | ||
return ($this -> hasWheels)? "has wheels" : "no wheels"; | ||
} | ||
} | ||
minicar $m=new minicar(); | ||
$m->setmodel("ram"); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
interface findarea | ||
{ | ||
function area(); | ||
} | ||
|
||
class rectangle implements findarea | ||
{ | ||
public $ln; | ||
public $b; | ||
public function __construct($l,$c) | ||
{ | ||
$this->ln=$l; | ||
$this->b=$c; | ||
} | ||
function area() | ||
{ | ||
$area = $this->ln*$this->b; | ||
echo "Area of Rectanle :".$area."<br>"; | ||
} | ||
} | ||
|
||
class square extends rectangle | ||
{ | ||
public $si; | ||
public function __construct($s) | ||
{ | ||
$this->si=$s; | ||
} | ||
function area() | ||
{ | ||
$area = $this->si*$this->si; | ||
echo "Area of Square :". $area."<br>"; | ||
} | ||
} | ||
|
||
class circle | ||
{ | ||
public $ra; | ||
public function __construct($r) | ||
{ | ||
$this->ra=$r; | ||
} | ||
function area() | ||
{ | ||
$area = 0.5*$this->ra*$this->ra; | ||
echo "Area of Circle :". $area."<br>"; | ||
} | ||
} | ||
|
||
$fr = new rectangle(3,2); | ||
$fr->area(); | ||
|
||
$fs = new square(5); | ||
$fs->area(); | ||
|
||
$fc = new circle(6); | ||
$fc->area() | ||
?> | ||
|
||
|
||
|
||
|
Oops, something went wrong.