0% found this document useful (0 votes)
4 views13 pages

Program Number 12: Biodata Date: 20/09/23 Create A PHP Program To Display The Bio Data of A Person by Reading The Personal Details Using An HTML Page

The document contains a series of PHP programs designed to perform various tasks such as displaying biodata, reversing a string, checking number types, creating a login page, generating pay slips, managing cookies, and handling product inventory. Each program includes HTML forms for user input and PHP scripts to process the data and display results. The document also outlines the input design for each program, indicating the expected user interactions.
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)
4 views13 pages

Program Number 12: Biodata Date: 20/09/23 Create A PHP Program To Display The Bio Data of A Person by Reading The Personal Details Using An HTML Page

The document contains a series of PHP programs designed to perform various tasks such as displaying biodata, reversing a string, checking number types, creating a login page, generating pay slips, managing cookies, and handling product inventory. Each program includes HTML forms for user input and PHP scripts to process the data and display results. The document also outlines the input design for each program, indicating the expected user interactions.
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/ 13

Program number 12 : Biodata Date : 20/09/23

Create a PHP program to display the bio data of a person by reading the
personal details using an HTML page.

<html>
<body>
<h1>BIO DATA</h1>

<form action="" method="post">


Name:<input type="text" name="name" /><br>
Date of birth :<input type="text" name="dob" /><br>
Gender :<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female<br>
Educational qualification : <select name="qualification">
<option value="Plus Two">Plus Two</option>
<option value="Degree">Degree</option>
<option value="PG">PG</option>
</select><br>
Name of father :<input type="text" name="fname" /><br>
Name of mother :<input type="text" name="mname" /><br>
Phone number:<input type="number" name="phone"><br>
<input type="submit" value="Submit" /><br>
</form>

</body>
</html>

<?php
if($_POST)
{
$name=$_POST['name'];
$dob=$_POST['dob'];
$gender=$_POST['gender'];
$qualification=$_POST['qualification'];
$fname=$_POST['fname'];
$mname=$_POST['mname'];
$phone=$_POST['phone'];
echo "<br><br><b>Personal Details<br>";
echo "..................................<br>";
echo "Name : $name <br>";
echo "Date of Birth : $dob <br>";
echo "Gender : $gender <br>";
echo "Qualification : $qualification <br>";
echo "Name of father : $fname <br>";
echo "Name of mother : $mname <br>";
echo "Phone number : $phone <br><b>";
}
?>

Input Design:

Program number 13 : Reverse a String Date : 20/09/23

Write a PHP function to reverse a string.

<html>
<body>
<form action="" method="post">
Enter the string :<input type="text" name="str" /><br>
<input type="submit" value="Reverse" /><br>
</form>
</body>
</html>
<?php
if($_POST)
{
$str=$_POST['str'];
reverse($str);
}
function reverse($str)
{
$length = strlen($str);
for ($i=($length-1) ; $i >= 0 ; $i--)
{
echo $str[$i];
}
}
?>

Input Design:

Program number 14 : Perfect, Abundant, Deficient Date : 20/09/23

Write a PHP program to check whether a given number is perfect, abundant or


deficient.

<html>
<body>
<h3>Enter the Number</h3><br>
<form action="" method="post">
<input type="text" name="number" />
<input type="submit" />
</form>
</body>
</html>
<?php
if($_POST)
{
$no = $_POST['number'];
$sum = 0;
for ($i = 1; $i < $no; $i++)
{
if ($no % $i == 0)
$sum = $sum + $i;
}
if( $sum == $no )
echo "Perfect Number";
else if($sum > $no)
echo "Abundant Number";
else
echo "Deficient Number";
}
?>

Input Design:

Program number 15 : Login Page Date : 26/09/23

Create a login page using database.

<html>
<head>
</head>
<body>
<form action="" method="POST">
Username:<input type="text" name="usr"><br><br>
Password:<input type="password" name="pass"><br><br><br>
<input type="submit" value="login">
</form>
</body>
</html>
<?php
if($_POST)
{
$usr1=$_POST['usr'];
$paswd=$_POST['pass'];
$con=pg_connect("host=localhost dbname=college user=postgres
password=ihrd2020");
if($con)
{
echo "Successfully Connected.......";
$qry="select username,password from login where username='$usr1' and
password='$paswd' ";
$result=pg_query($con,$qry);
$nos=pg_num_rows($result);
if($nos)
echo " <br> $usr1, You are Logged Successfully...";
else
echo "Login Denied";
}
else
echo "no connection";
}
?>

Input Design:

Program number 16 : Mark List Date : 26/09/23

Create a table student with fields roll no, name, mark, grade. Insert some
records in the table. Write a PHP program to display the mark list of a student
by accepting the register no of the student.

<html>
<head>
<title>Marklist</title>
</head>
<body>
<h3>Marksheet</h3>
<form method="POST" action="">
Regno:<input type="text" name="reg"/><br><br><br>
<input type="submit" value="show">
</form>
</body>
</html>

<?php
if($_POST)
{
$rg=$_POST['reg'];
$con=pg_connect("host=localhost dbname=college user=postgres
password=ihrd2020");
if($con)
{
echo "Successfully Connected...";
$qry="SELECT * FROM marklist where rollno ='$rg'";
$result=pg_query($con,$qry);
$nos=pg_num_rows($result);

while($row=pg_fetch_row($result))
{
echo "<br>\n";
echo "rollno: $row[0] <br> name: $row[1] <br> mark: $row[2] <br> grade:$row[3]";
}
}
else
echo "No connection";
}
?>

Input Design:
Program number 17 : Pay Slip Date : 04/10/23

Write a PHP application to generate the pay slip of an employee by accepting


name, basic salary and designation. The net salary will be calculated based on
the following conditions.

P6.html

<html>
<head>
<title>Employee details</title>
</head>
<body>
<form action="p6.php" method="post">
<center> <h1>Employee details</h1> </center>
<br><br><br>
<table align = "center">
<tr>
<td>Employee Name</td>
<td><input type="text" name="nam"></td>
</tr>
<tr>
<td>Employee designation</td>
<td><select name="design">
<option selected value="Manager">Manager</option>
<option value="Supervisor">Supervisor</option>
<option value="Clerk">Clerk</option>
<option value="Peon">Peon</option></select>
</td></tr>
<tr>
<td>Basic Salary</td>
<td><input type="text" name="sal"></td></tr>
<tr></tr>
<tr><td></td><td><input type="submit" value="SUBMIT">
</td></tr>
</table>
</form>
</body>
</html>

p6.php

<html>
<head><title>employee salary</title></head>
<body>
<?php
$na=$_POST["nam"];
$des=$_POST["design"];
$basic=$_POST["sal"];
switch($des)
{
case 'Manager':
$ca=1000;
$ea=500;
break;
case 'Supervisor':
$ca=750;
$ea=200;
break;
case 'Clerk':
$ca=500;
$ea=100;
break;
case 'Peon':
$ca=250;
$ea=0;
break;
}
$hra=0.25*$basic;
$gross=$basic+$ca+$ea+$hra;
if($gross>5000)
$it=$gross*0.08;
else if($gross>4000)
$it=$gross*0.05;
else if($gross>2500)
$it=$gross*0.03;
else
$it=0;
$net=$gross-$it;
echo "<table border=1 rules=all width=50%>
<tr><td colspan=2 align=center><strong>PAYSLIP</strong></td></tr>
<tr>
<td width=50%>Employee Name</td>
<td width=50%>$na</td>
</tr>
<tr>
<td width=50%>Designation</td>
<td width=50%>$des</td>
</tr>
<tr bgcolor=eeeee>
<td>Salary Component</td><td>Amount(in Rs)</td></tr>
<tr>
<td>Basic Salary</td>
<td>$basic</td>
</tr>
<tr>
<td>Conveyance Allowance</td>
<td>$ca</td>
</tr>
<tr>
<td>extra allowance</td>
<td>$ea</td>
</tr>
<tr>
<td>House rent allowance</td>
<td>$hra</td>
</tr>
<tr bgcolor=eeeeee>
<td>Gross Salary</td>
<td>$gross</td>
</tr>
<tr bgcolor=eeeeee>
<td>Income tax Deduction</td>
<td>$it</td>
</tr>
<tr bgcolor=eeeeee>
<td><strong>Net Salary</strong></td>
<td><h3>$net</h3></td>
</tr>
</table>";
?>
<input type=button name=click value="prepare another payslip" onclick=
"parent.location='p6.html' ">
</body>
</html>

Input Design:

Program number 18 : Cookie Date : 04/10/23

PHP program to store current date-time in a cookie and display the Last visited
date-time on the web page upon revisiting the same web page.

<html>
<body bgcolor="yellow">
<h2> Last visited time on the web page</h2>
<br>
<?php
$intm = 60 * 60 * 24 * 60 + time();
setcookie('lastVisit', date("G:i - m/d/y"), $intm);
if(isset($_COOKIE['lastVisit']))
{
$visit = $_COOKIE['lastVisit'];
echo "Your last visit was - ". $visit;
}
else
echo "You have got some state cookies!";
?>
</body>
</html>

Input Design:

No input design

Program number 19 : Product Date : 04/10/23

Create a table product with fields itemcode, itemname, unitprice. Write PHP
program to insert 5 records into the table and display it in a table format.

P8.html

<html>
<head>
<title>Stock details</title>
</head>
<body>
<form action="p8.php" method="post">
<center>
<h1>Stock Details</h1>
<table>
<tr>
<td>Item code</td>
<td><input type="text" name="code"></td>
</tr>
<tr>
<td>Item name</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>Price</td>
<td><input type="text" name="price"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="SUBMIT"></td>
</tr>
</table>
</center>
</form>
</body>
</html>
<html>
<body>

p8.php

<html>
<body>
<?php
$code=$_POST['code'];
$name=$_POST['name'];
$price=$_POST['price'];
$con=pg_connect("host=localhost dbname=college user=postgres
password=ihrd2020") or die("Cannot Connect");
$sql="INSERT INTO product VALUES('$code','$name','$price')";
$res=pg_query($con,$sql);
if($res){
echo "New record created successfully";
}
else
{
echo "Cannot insert".pg_last_error();
exit(0);
}
$sql="SELECT * from product";
$result=pg_query($con,$sql);
if(!$result){
echo "Could not run query:".pg_last_error();
}
echo"<h2>INVENTORY DETAILS</h2>";
echo "<br>";
echo "<table border=2>
<tr>
<th>Item code</th>
<th>Item Name</th>
<th>unit price</th>
</tr><tr>";
while($row=pg_fetch_row($result))
{
echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td></tr>";
}
?>
<form>
<input type="button" name="click" value="Insert again"
onclick="parent.location='p8.html'">
</body>
</form>
</html>

Input Design:

You might also like