hello again..
i need some advice about problem described below.
so:
i have form where i enter some text
[i]here is the form
[code]<form action=”index.php?p=itm1″ method=”post”>
<table height=”100″ border=”0″ cellpadding=”0″ cellspacing=”0″>
<TR><TD colspan=”3″><i>some text</i></TD></TR>
<TR>
<TD align=”center”>enter new name : </TD>
<TD align=”center”><input type=”text” name=”item”></TD>
<TD align=”center”><input type=”submit” value=”add”></TD>
</TR>
</table>
</form>
after this text inserted into form as u see is sent to php file called itm1.php
[i]here is the code of that page
[code]<?php
include(“includes/vars.php”);
$item = $_POST[‘item’];
if ($_POST[‘item’]=$item)
{
mysql_connect(“$hostname”, “$username”, “$password”) or die(mysql_error());
mysql_select_db(“$db”) or die(mysql_error());
mysql_query(“CREATE TABLE IF NOT EXISTS menu(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
item VARCHAR(300)) “) or die(mysql_error());
mysql_query(“INSERT INTO menu (item)
VALUES(‘$item’)”) or die(mysql_error());
print “<br />”;
echo “ new item named <b>$item</b> has been added”;
print “<br />”;
}
else
{
echo “error.. error description”;
}
?>
if “if” statmant is true it adds new item to db and echos “new item has been added” so everything goes fine.. but
when i refresh the page post data is added to database again..
how can i avoid this? i want if someone refreshes the page … to do something else but not to add the same item again to database.
thanks