kenek
-
Posts
7 -
Joined
-
Last visited
Never
Posts posted by kenek
-
-
Ok, thanks anyway. Would it be of any use if I post this on the PHP Freaks Apache forum, or are the posters there the same as here?
Otherwise I'll just try to install everything again. I want to install it manually, I did it before, and it worked fine.. -
Does nobody have any idea??
-
I already supposed there was nothing wrong with the code.. But I can't figure out what is causing the malfunction. I am on winxp and used these steps to install php: http://iamcode.net:64/projects/apache/php-win.awk - maybe something went wrong in that process?
I really hope someone might have some suggestions still, because I'm stuck right now. -
Thanks Ken.
[code]
<?php echo '<pre>' . print_r($_POST,true) . '</pre>'; ?>
[/code]
prints out:
Array
(
)
Above the other output, which stays the same.
I also tried the test script, but that doesn't work either. When I press the "Send" button, the page 'refreshes' and nothing happens... -
I figured it wasn't working by trying to run the following example.
orderform.html:
[code]
<html>
<body>
<form action="processorder.php" method="post">
<table border="0">
<tr bgcolor="#cccccc">
<td width="150">Item</td>
<td width="15">Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td align="center"><input type="text" name="tireqty" size="3"
maxlength="3"></td>
</tr>
<tr>
<td>Oil</td>
<td align="center"><input type="text" name="oilqty" size="3" maxlength="3"></td>
</tr>
<tr>
<td>Spark Plugs</td>
<td align="center"><input type="text" name="sparkqty" size="3"
maxlength="3"></td>
</tr>
<tr>
<td>How did you find us?</td>
<td><select name="find">
<option value = "a">I'm a regular customer</option>
<option value = "b">TV advertising</option>
<option value = "c">Phone directory</option>
<option value = "d">Word of mouth</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Submit Order"></td>
</tr>
</table>
</form>
</body>
</html>
[/code]
processorder.php:
[code]
<?php
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty = $_POST['sparkqty'];
$find = $_POST['find'];
?>
<html>
<head>
<title>Order Results</title>
</head>
<body>
<?php
echo '<p>Order processed at ';
echo date('H:i, jS F');
echo '</p>';
echo '<p>Your order is as follows: </p>';
$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
echo 'Items ordered: '.$totalqty.'<br />';
if( $totalqty == 0)
{
echo 'You did not order anything on the previous page!<br />';
}
else
{
if ( $tireqty>0 )
echo $tireqty.' tires<br />';
if ( $oilqty>0 )
echo $oilqty.' bottles of oil<br />';
if ( $sparkqty>0 )
echo $sparkqty.' spark plugs<br />';
}
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);
$totalamount = $tireqty * TIREPRICE
+ $oilqty * OILPRICE
+ $sparkqty * SPARKPRICE;
echo 'Subtotal: $'.number_format($totalamount,2).'<br />';
$taxrate = 0.10;
$totalamount = $totalamount * (1 + $taxrate);
echo 'Total including tax: $'.number_format($totalamount,2).'<br />';
if($find == 'a')
echo '<p>Regular customer.</p>';
elseif($find == 'b')
echo '<p>Customer referred by TV advert.</p>';
elseif($find == 'c')
echo '<p>Customer referred by phone directory.</p>';
elseif($find == 'd')
echo '<p>Customer referred by word of mouth.</p>';
else
echo '<p>We do not know how this customer found us.</p>';
?>
</body>
</html>
[/code]
Sorry for the long code, I picked this example because I know it was working before the re-install. No matter what I put in the orderform, I always get the same output:
"Order processed at 18:55, 22nd July
Your order is as follows:
Items ordered: 0
You did not order anything on the previous page!
Subtotal: $0.00
Total including tax: $0.00
We do not know how this customer found us."
That's why I thought the variables aren't passed on the PHP. I'm running Apache on Windows XP, by the way. -
I have just re-installed php (version 5.2.0-dev), and it's not working right. I think I have installed it properly, phpinfo() is working, but variables from a html form ($_POST['variablename'], for example) aren't passed on to PHP, it just doesn't reveive anything.. Before the re-install everything worked fine (...).
I am pretty clueless as to what might be causing this. Any help or thoughts would be appreciated.
Problem with $_POST[''] variables
in PHP Coding Help
Posted