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>

Monday, 18 November 2019

2. processed form


Target: Create a response page which shows result of  submitting customer form.

After Submission we wish to show order result, for that purpose we make a another below page for order proceed result.
<html>
<head>
<title>Form Proceed</title>
</head>
<body>
<h1>Anika Stationery</h1>
<h2>Order result</h2>
<h5>Order Processed</h5>

</body>
</html>
 Save as processedform.php
But html is a static language, so in that above case ( <h5>Order Processed</h5>) always shows order proceed eithr it has done or not .
So, here we use php statement to show order result “Order Processed”.
So instead upper code you should use

<html>
<head>
<title>Form Proceed</title>
</head>
<body>
<h1>Anika Stationery</h1>
<h2>Order result</h2>
<?php
echo "order Proceed";
?>
</body>
</html>

Now we want to add dynamic content in program like show date and time .
So here we have to edit above php code. (editing Shows in blue colour in below code).
<html>
<head>
<title>Form Proceed</title>
</head>
<body>
<h1>Anika Stationery</h1>
<h2>Order result</h2>
<?php
echo "order Proceed at ";
echo date("l jS \of F Y h:i:s A");
?>
</body>
</html>

Here,
H presents : 24 hour
I presents : minute  with leading zero if required.
J presents: day of the month without a leading zero
S: presents ordinal suffix(th)
F: presents full name of month.

Output:

Anika Stationery

Order result

order Proceed at11:28,1823,November


2. Processed Form


After Submisssion we wish to show order result, for that purpose we make a another below page for order proceed result.
<html>
<head>
<title>Form Proceed</title>
</head>
<body>
<h1>Anika Stationery</h1>
<h2>Order result</h2>
<h5>Order Processed</h5>

</body>
</html>
 Save as processedform.php
But html is a static language, so in that above case ( <h5>Order Processed</h5>) always shows order proceed eithr it has done or not .
So, here we use php statement to show order result “Order Processed”.
So instead upper code you should use

<html>
<head>
<title>Form Proceed</title>
</head>
<body>
<h1>Anika Stationery</h1>
<h2>Order result</h2>
<?php
echo "order Proceed";
?>
</body>
</html>

Now we want to add dynamic content in program like show date and time .
So here we have to edit above php code. (editing Shows in blue colour in below code).
<html>
<head>
<title>Form Proceed</title>
</head>
<body>
<h1>Anika Stationery</h1>
<h2>Order result</h2>
<?php
echo "order Proceed at";
echo date('H:i,js,F');
?>
</body>
</html>

In code echo date('H:i,js,F')
Here,
H presents : 24 hour
I presents : minute  with leading zero if required.
J presents: day of the month without a leading zero
S: presents ordinal suffix(th)
F: presents full name of month.


Saturday, 2 November 2019

1. Create Form

Create a form where Customer fill quantity of item:

<html>
<head>
<title>Book Store</title>
</head>
<body>
<form method="POsT" action="process.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"></td>
</tr>
<tr>
<td width="150">Pencil</td>
<td width="70"><input type="text" size="3"></td>
</tr>
<tr>
<td width="150">Pen</td>
<td width="70"><input type="text" size="3"></td>
</tr>
<tr colspan="2">
<td align="center"><input type="submit" value="submit order"></td>
</tr>
</table>
</form>
</body>
</html>

Output:

After submit order by customer , we want response page like:

Anika Stationery

Order result

order Proceed at11:28,1823,November

So, in next blog we will try to make such response page.

Ch-16 Associate Array