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

php_sem_II_prog

The document consists of multiple HTML and PHP files that handle form submissions for various applications, including font style selection, user login, employee details entry, and customer information collection. Each PHP file processes the submitted data, sets cookies or sessions, and displays the results back to the user. The applications demonstrate basic web form handling and data persistence using cookies and sessions.

Uploaded by

Monika Kate
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)
9 views

php_sem_II_prog

The document consists of multiple HTML and PHP files that handle form submissions for various applications, including font style selection, user login, employee details entry, and customer information collection. Each PHP file processes the submitted data, sets cookies or sessions, and displays the results back to the user. The applications demonstrate basic web form handling and data persistence using cookies and sessions.

Uploaded by

Monika Kate
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/ 8

SetA1

HTML file :

<html>
<body>
<form action="slip21_2_1.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>

PHP file : slip21_2_1.php


<?php
echo "style is ".$_GET['s1']."<br>color is ".$_GET['c']."<br>Background color is ".
$_GET['b']."<br>size is ".$_GET['s'];
setcookie("set1",$_GET['s1'],time()+3600);
setcookie("set2",$_GET['c'],time()+3600);
setcookie("set3",$_GET['b'],time()+3600);
setcookie("set4",$_GET['s'],time()+3600);
?>
<html>
<body>
<form action="slip21_2_2.php">
<input type=submit value=OK>
</form>
</body>
</html>

PHP file : slip21_2_2.php


<?php
$style = $_COOKIE['set1'];
$color = $_COOKIE['set2'];
$size = $_COOKIE['set4'];
$b_color = $_COOKIE['set3'];
$msg = "NR Classes";
echo "<body bgcolor=$b_color>";
echo "<font color=$color size=$size>$msg";
echo "</font></body>";
?>
Setb_1

<form method="POST" action="login.php">

<label for="username">Username:</label>

<input type="text" id="username" name="username" required><br>

<label for="password">Password:</label>

<input type="password" id="password" name="password" required><br>

<input type="submit" value="Login">

</form>

<?php

// Define the correct username and password

$correctUsername = "admin";

$correctPassword = "password";

// Get the submitted username and password

$username = $_POST['username'];

$password = $_POST['password'];

// Check if the submitted username and password match the correct ones

if ($username === $correctUsername && $password === $correctPassword) {

// Display the welcome message on the second form

echo "<form>";

echo "<h2>Welcome, $username!</h2>";

echo "</form>";

} else {

// Display an error message

echo "<h2>Error: Invalid username or password.</h2>";

?>
Setb_2

HTML file :

<html>
<body>
<form action="slip18_2_1.php" method="get">
<center> <h2>Enter Enployee Details :</h2> <br>

<table>
<tr> <td><b>Emp no :</b></td> <td><input type=text name=eno></td> </tr>
<tr> <td><b> Name :</b></td> <td><input type=text name=enm></td> </tr>
<tr> <td><b>Address :</b></td> <td><input type=text name=eadd></td>
</tr>
</table>
<br> <input type=submit value=Show name=submit>
</center>
</form>
</body>
</html>

PHP file : slip_18_2_1.php

<?php
session_start();
$eno = $_GET['eno'];
$enm = $_GET['enm'];
$eadd = $_GET['eadd'];

$_SESSION['eno'] = $eno;
$_SESSION['enm'] = $enm;
$_SESSION['eadd'] = $eadd;
?>

<html>
<body>

<form action="slip18_2_2.php" method="post">


<center>
<h2>Enter Earnings of Employee:</h2>

<table>
<tr><td>Basic : </td><td><input type="text" name="e1"></td><tr>
<tr><td>DA : </td><td><input type="text" name="e2"></td></tr>
<tr><td>HRA : </td><td><input type="text" name="e3"></td></tr>
<tr><td></td><td><input type="submit" value=Next></td></tr>
</table>
</center>
</form>
</body>
</html>

PHP file : slip18_2_2.php


<?php
session_start();
$e1 = $_POST['e1'];
$e2 = $_POST['e2'];
$e3= $_POST['e3'];

echo "<h3>Employee Details</h3> ";


echo "Name : ".$_SESSION['eno']."<br>";
echo "Address : ".$_SESSION['enm']."<br>";
echo "Class : ".$_SESSION['eadd']."<br><br>";

echo "basic : ".$e1."<br>";


echo "DA : ".$e2."<br>";
echo "HRA : ".$e3."<br>";

$total = $e1+$e2+$e3;
echo "<h2>Total Of Earnings Is : ".$total."</h2>";
?>

Setc

first.php

<html>

<body>

<form method ="post" action="second.php">

<table border="1">

<tr>

<td>customer Name:-</td>

<td><input type="text" name="name"></td>

</tr> <tr><td>customer Phone Number:-</td>


<td><input type="text" name="ph-no"></td></tr>

<tr><td>customer address:-</td>

<td><input type="text" name="address"></td>

</tr> <tr><td></td>

<td><input type="submit" value="save"></td>

</tr>

</table>

</form></body></html>

second.php

<html>

<body>

<?php

setCookie('name',$_POST["name"]);

setCookie('ph-no',$_POST["ph-no"]);

setCookie('address',$_POST["address"]);

echo"Hello".$_POST["name"]."!Enter Details....<br>";

?>

<form method ="post" action="third.php">

<table border="1">

<tr><td>Product name</td><td><input type="text" name="pname"></td></tr>


<tr><td>qty</td><td><input type="text" name="qty"></td></tr>

<tr><td>rate</td><td><input type="text" name="rate"></td></tr>

<tr><td></td><td><input type="submit" name="submit" value="DISPLAY"></td></tr>

</table>

</form>

</body>

</html>

third.php

<html>

<body>

<?php

echo "<b> customer Details</b><br>";

echo "<table border='1'>";

echo "<tr><td>";

echo"customerName:".$_COOKIE["name"]."<br>";

echo "</tr></td>";
echo "<tr><td>";

echo"customer phone:-".$_COOKIE["ph-no"]."<br>";

echo "</tr></td>";

echo "<tr><td>";

echo"Studcustomerent address:-".$_COOKIE["address"]."<br>";

echo "</tr></td>";

echo "<tr><td>";

echo "<b> customer Bill</b><br>";

echo "</tr></td>";

echo "<tr><td>";

echo"pname:".$_REQUEST["pname"];echo "</tr></td>";

echo "<tr><td>";

echo"qty:".$_REQUEST["qty"];echo "</tr></td>";

echo "<tr><td>";

echo"rate:".$_REQUEST["rate"];echo "</tr></td>";

echo "</table>";
if(isset($_POST['submit']))

$qty=(int)$_POST['qty'];

$rate=(int)$_POST['rate'];

$total = $qty*$rate;

echo"Total=".$total;

?>

</body>

</html>

You might also like