php II practicals
php II practicals
Create Registration Page which Store data in a user class and display all the
information on next page.
=> html file
<!DOCTYPE html>
<html>
<head>
<title>Registration Page</title>
</head>
<body>
<h2 style="color:blue" align="center">Registration Page</h2>
<form name="frm" method="post" action="dbregister.php">
<table border="1" align="center">
<tr>
<td>User Name</td>
<td><input type="text" name="uname"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="upwd"></td>
</tr>
<tr>
<td>Re-type Password</td>
<td><input type="password" name="urepwd"></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="uemail"></td>
</tr>
<tr>
<td>Age</td>
<td><input type="text" name="uage"></td>
</tr>
<tr>
<td>Gender</td>
<td><input type="radio" name="ugender" value="Male"/>Male
<input type="radio" name="ugender"
value="Female"/>Female</td>
</tr>
<tr>
<td>Hobbies</td>
<td><input type="checkbox" name="reading" value="0"/>Reading
<input type="checkbox" name="music" value="1"/>Music
<input type="checkbox" name="dance" value="2"/>Dance</td>
</tr>
<tr align="center">
<td colspan="2" a><input type="submit" name="btnregister"
value="Register"></td>
</tr>
</table>
</form>
</body>
</html>
db file
=><?php
class user
{
var $name,$password,$email,$age,$gender,$hobbies;
function getdata($a,$b,$c,$d,$e,$f,$g,$h)
{
$this->name=$a;
$this->password=$b;
$this->email=$c;
$this->age=$d;
$this->gender=$e;
$this->reading=$f;
$this->music=$g;
$this->dance=$h;
}
function display()
{
echo $this->name."<br/>";
echo $this->password."<br/>";
echo $this->email."<br/>";
echo $this->age."<br/>";
echo $this->gender."<br/>";
if($this->reading==0)
{
echo $this->reading."<br/>";
}
if($this->music==1)
{
echo $this->music."<br/>";
}
if($this->dance==2)
{
echo $this->dance."<br/>";
}
}
}
if(isset($_POST["btnregister"]))
{
$name=$_POST["uname"];
$password=$_POST["upwd"];
$email=$_POST["uemail"];
$age=$_POST["uage"];
$gender=$_POST["ugender"];
$reading=$_POST["reading"];
$music=$_POST["music"];
$dance=$_POST["dance"];
?>
3. Create a vehicle class and show the use of constructor and destructor in
php.
=><?php
class vehicle
{
var $a,$b;
public function __construct()
{
echo "vehicle constructor called"."<br/>";
}
public function __destruct()
{
echo "destroy the constructor";
}
}
class bike extends vehicle
{
public function __construct()
{
parent::__construct();
}
public function __destruct()
{
parent::__destruct();
}
}
$a=new vehicle();
?>
4. Create a class figure and show the use of method overriding in php.
=>
<?php
class Figure
{
var $length;
function setlength($n)
{
$this->length=$n;
}
function ldisplay()
{
echo $this->length;
}
}
class Rectangle extends Figure
{
var $breadth;
function setbreadth($n2)
{
$this->breadth=$n2;
}
function bdisplay()
{
echo $this->breadth;
}
public function area()
{
return ($this->length*$this->breadth);
}
}
$f=new Figure();
$f->setlength(10);
echo "length :-";
echo $f->ldisplay()."<br/>";
echo"Area of figure class is :-". $f->area()."<br/>";
$R=new Rectangle();
$R->setbreadth(20);
$R->setlength(10);
echo "breadth :-";
echo $R->bdisplay()."<br/>";
$R->setlength(10);
echo "Area of Rectangle class is :-" .$R->area()."<br/>";
?>
5. Create wordpress blog for cloth store.
6.Create a category of your blog fashion and add some blog in that category.
7.Insert 5 images for post in media library and use this images in post.
1st post
2nd Post
3rd Post
4th Post
5th Post