Jump to content

Recommended Posts

HI, I have been learning PHP from a book for some time, my problem is that I cant get PHP to display the number of items that were enter in orderform.html into processorder.php.

 

Thanks for any help in advance, if I didnt explain my problem so well tell me.

 

--------------------------------------------------------------------------------------

orderform.html

--------------------------------------------------------------------------------------

<HTML>

<HEAD>

<TITLE>Order Form</TITLE>

</HEAD>

<BODY>

 

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

<table border="0">

<tr bgcolor="#cccccc">

<td width="150">Item</td>

<td width="12">Quantity</td>

</tr>

<tr>

<td>Tires</td>

<td align="center"><input type="text" name="tireqty" size="3"

maxlenght="3" /></td>

</tr>

<tr>

<td>Oil</td>

<td align="center"><input type="text" name="oilqty" size="3"

maxlenght="3" /></td>

</tr>

<tr>

<td>Sparks Plugs</td>

<td align="center"><input type="text" name="sparkqty" size="3"

maxlenght="3" /></td>

</tr>

<tr>

<td colspan="2" align="center"><input type="submit" value="Submit Order" /></td>

</tr>

</table>

</form>

 

</BODY>

</HTML>

 

---------------------------------------------------------------------------------

processorder.php

---------------------------------------------------------------------------------

<?php

// create short variable names

$tireqty = $_POST [ ' tireqty ' ] ;

$oilqty = $_POST [ ' oilqty ' ] ;

$sparkqty = $_POST [ ' sparkqty ' ] ;

?>

 

<HTML>

<HEAD>

<TITLE>Bob's Auto Parts - Order Results</TITLE>

</HEAD>

<BODY>

<h1>Bob's Auto PArts </h1>

<h2>Order Results</h2>

 

<?php

echo '<p>Order processed at ' ;

echo date ( ' H:i, jS F ' ) ;

echo '</p>' ;

 

echo ' <p>Your order is as follows: </p> ' ;

 

echo $tireqty. ' tires<br /> ' ;

echo $oil1qty. ' bottles of oil<br /> ' ;

echo $sparkqty. ' spark plugs<br /> ' ;

?>

 

</BODY>

</HTML>

 

 

try this:

 

processorder.php

<?php
// create short variable names
$tireqty = $_POST ['tireqty'] ;
$oilqty = $_POST ['oilqty'] ;
$sparkqty = $_POST ['sparkqty'] ;
?>

<HTML>
<HEAD>
<TITLE>Bob's Auto Parts - Order Results</TITLE>
</HEAD>
<BODY>
<h1>Bob's Auto PArts </h1>
<h2>Order Results</h2>

<?php
echo '<p>Order processed at ' ;
echo date ( ' H:i, jS F ' ) ;
echo '</p>' ;

echo ' <p>Your order is as follows: </p> ' ;

echo $tireqty. 'tires' ;
echo "<br>";
echo $oilqty. 'bottles of oil' ;
echo "<br>";
echo $sparkqty. 'spark plugs' ;
?>

</BODY>
</HTML>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.