Variables de un Formulario; Ayuda!
Publicado por Programador Principiante (1 intervención) el 23/03/2011 22:05:41
Buenas, que tal?
Les cuento mi problema: estoy aprendiendo PHP, y estoy haciendo un formulario simple, donde introduzco datos, y al mandarlos, me dirije a una página de confirmación.
Hasta ahí, todo bien. El tema se presenta cuando quiero hacer que los valores que se introdujeron en la primer página, aparezcan en la de la confirmación de la orden.
No se donde definir las variables; se que las tengo que asignar así:
<?php
//crear nombres de variables cortos
$tireqty = $HTTP_POST_VARS['tireqty'];
$oilqty = $HTTP_POST_VARS['oilqty'];
$sparkqty = $HTTP_POST_VARS['sparkqty'];
?>
(pero no sé donde poner ese bloque)
Les paso los códigos fuentes:
Formulario:
<html>
<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 colspan="2" align="center"><input type="submit" value="Submit Order" /></td>
</tr>
</table>
</form>
</html>
Processorder.php:
<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 $oilqty.' bottles of oil<br />';
echo $sparkqty.' spark plugs<br />';
?>
</body>
</html>
Les cuento mi problema: estoy aprendiendo PHP, y estoy haciendo un formulario simple, donde introduzco datos, y al mandarlos, me dirije a una página de confirmación.
Hasta ahí, todo bien. El tema se presenta cuando quiero hacer que los valores que se introdujeron en la primer página, aparezcan en la de la confirmación de la orden.
No se donde definir las variables; se que las tengo que asignar así:
<?php
//crear nombres de variables cortos
$tireqty = $HTTP_POST_VARS['tireqty'];
$oilqty = $HTTP_POST_VARS['oilqty'];
$sparkqty = $HTTP_POST_VARS['sparkqty'];
?>
(pero no sé donde poner ese bloque)
Les paso los códigos fuentes:
Formulario:
<html>
<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 colspan="2" align="center"><input type="submit" value="Submit Order" /></td>
</tr>
</table>
</form>
</html>
Processorder.php:
<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 $oilqty.' bottles of oil<br />';
echo $sparkqty.' spark plugs<br />';
?>
</body>
</html>
Valora esta pregunta


0