Tuesday, 19 November 2019

3. Data transmission in another page


In this session we learn, how to show entered data in another page.
Fro that above mentioned purpose we have to do add some code in first program(orderform.php)
Changes shows in blue color (     ) in program
<html>
<head>
<title>Book Store</title>
</head>
<body>
<form method="POST" action="processedform.php" >
<table>
<tr bgcolor="red">
<td width="150">Product</td>
<td width="70">Quantity</td>
</tr>
<tr>
<td width="150">Book</td>
<td width="70"><input type="text" size="3" name="book"></td>
</tr>
<tr>
<td width="150">Pencil</td>
<td width="70"><input type="text" size="3" name="pencil"></td>
</tr>
<tr>
<td width="150">Pen</td>
<td width="70"><input type="text" size="3" name="pen"></td>
</tr>
<tr colspan="2">
<td align="center"><input type="submit" value="submit order" name="submit"></td>
</tr>
</table>

</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$book=$_POST['book'];
$pencil=$_POST['pencil'];
$pen=$_POST['pen'];
}

?>

Also we have to add some code in another response page which shows quantity of order.
Addition of code represent by  blue (  ) colour.
<html>
<head>
<title>Form Proceed</title>
</head>
<body>
<h1>Anika Stationery</h1>
<h2>Order result</h2>
<?php
$book=$_POST['book'];
$pencil=$_POST['pencil'];
$pen=$_POST['pen'];
echo "order Proceed at ";
echo date("l jS \of F Y h:i:s A");
echo "Your Order List as follow:<br>";
echo "book: $book";
echo nl2br("\n pencil: $pencil");
echo "<br> pen: $pen";
?>
</body>
</html>

No comments:

Post a Comment

Ch-16 Associate Array