Quick Question form submission
Hi, I am entering multiple data into a sql database via a form.
At the moment when you submit the form, it simply says
"item added".
How do i get it to reshow the form when you click submit instead?
As this will make it far quicker in submitting new items.
here is my html code
Code:
<body>
<?php
if(isset($_POST['add']))
{
include 'config.php';
include 'connect.php';
$name = $_POST['name'];
$price = $_POST['price'];
$query = "INSERT INTO pricelist (name, price) VALUES ('$name', '$price')";
mysql_query($query) or die('Error, insert query failed');
mysql_close($conn);
echo "New Item Added";
}
else
{
?>
<form action="<? echo($PHP_SELF) ?>" method="post">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Name</td>
<td><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td width="100">Price</td>
<td><input name="price" type="text" id="price"></td>
</tr>
<tr>
<td width="100"></td>
<td></td>
</tr>
<tr>
<td width="100"></td>
<td><input name="add" type="submit" id="add" value="Add New Price"></td>
</tr>
</table>
</form>
<?php
}
?>
</body>
Many Thanks
Last edited by Brywright : 10-28-2008 at 10:44 AM.