0% found this document useful (0 votes)
3 views

php II practicals

The document outlines the creation of a registration page using HTML and PHP, where user data is collected and displayed. It also includes the implementation of a student class and a result class, demonstrating inheritance, as well as a vehicle class showcasing constructor and destructor usage. Additionally, it describes a figure class with method overriding and mentions creating a WordPress blog for a clothing store with specific posts and media integration.

Uploaded by

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

php II practicals

The document outlines the creation of a registration page using HTML and PHP, where user data is collected and displayed. It also includes the implementation of a student class and a result class, demonstrating inheritance, as well as a vehicle class showcasing constructor and destructor usage. Additionally, it describes a figure class with method overriding and mentions creating a WordPress blog for a clothing store with specific posts and media integration.

Uploaded by

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

1.

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"];

$ob= new user;


$ob->getdata($name,$password,$email,$age,$gender,$reading,$music,$dance);
$ob->display();
}
?>
2. Create class student and inherit this student class into result class.
=><?php
class student {
public $maths;
public $english;
public $computer;
public $science;
public $total;
public function __construct($maths,$english,$computer,$science)
{
$this->maths = $maths;
$this->english = $english;
$this->computer = $computer;
$this->science = $science;
}
public function marks()
{
echo "The Marks in maths,english,computer and science are {$this->maths} {$this->english} {$this-
>computer} {$this->science}"."<br/>";
}
public function total()
{
$total= ( $this->maths+$this->english+$this->computer+ $this->science);
return ( $total);
}

class result extends student {


public function message() {
echo "Result of Roll no. 4 =>";
}
}

$result = new result(20,30,40,45);


$result->message();
$result->marks()."</br>";
echo "Total Marks are =>".$result->total();

?>
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;
}

public function area()


{
return($this->length*$this->length);
#echo $this->length*$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

You might also like