display two values on page [message #181130] |
Thu, 18 April 2013 09:44 |
newbie php
Messages: 3 Registered: April 2013
Karma: 0
|
Junior Member |
|
|
Hi all,
I'm an absolute newbie to PHP, but I need to send two values to a php-page and multiplay to calculate costs for an order.
Simplified, i have a form that sends number and price to calculate.php.
code:
<form name="form" method="post" action="calculate.php">
<table border="0" cellspacing="5" cellpadding="10">
<tr>
<td>tickets</td>
<td><select name="number">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
<option value=6>6</option>
<option value=7>7</option>
<option value=8>8</option>
<option value=9>9</option>
<option value=10>10</option>
</select></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="button" id="button" value="calculate"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table><input name="price" type="hidden" value=6>
</form>
So the form sends the chosen number and the hidden value of 6 to calculate.php
Calculate php maltiplies both values. In code:
<html>
<head>Cost calculated</head>
<body>
<?php
$p=$_POST[price];
$n=$_POST[number];
$kosten = $p * $n;
echo $a "<br>"
echo $p "<br>"
echo $kosten "<br>"
?>
</body>
</html>
However, this results in a server-error.
Please, anybody, where do I go wrong?
Sybolt
|
|
|
|
|
|
|
|
|
|
Re: display two values on page [message #181140 is a reply to message #181137] |
Thu, 18 April 2013 16:46 |
Luuk
Messages: 329 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 18-04-2013 15:08, Jerry Stuckle wrote:
> It would be very easy for me to create a form on my own machine which
> sets a price of 1.
I would set it to zero.....
;)
|
|
|