session help
Posted: Wed Aug 25, 2004 11:54 pm
hello,
i have the follwing script. I thimk for you is prety obvious what it does and I don't have to explain, but if you want me to, pls tell me and I will.
Ok, what i want to do is after I insert data into the country filed and submit the form, if I want to refresh the page not to be able to. I want to receive a warning message that the page has expired. The same thing if I hit the back button of the browser. Now, I know hat this has to be done with sessions, but i don't know to well how it should be done. Pls don't write the script for me, but I would appreciate if you would advice me.
Thx
i have the follwing script. I thimk for you is prety obvious what it does and I don't have to explain, but if you want me to, pls tell me and I will.
Ok, what i want to do is after I insert data into the country filed and submit the form, if I want to refresh the page not to be able to. I want to receive a warning message that the page has expired. The same thing if I hit the back button of the browser. Now, I know hat this has to be done with sessions, but i don't know to well how it should be done. Pls don't write the script for me, but I would appreciate if you would advice me.
Thx
Code: Select all
$message = "";
if(isset($_POST['addCountry']))
{
$my_form_url = "http://localhost/index.php";
$my_form_url = strtolower($my_form_url);
$incoming_url = strtolower($_SERVER['HTTP_REFERER']);
if ($my_form_url == $incoming_url)
{
if ($_POST['country'] == "")
{
$message = "<span class='mesaj3'><li>You must fill all fields!</span>";
}
else
{
$sql = "SELECT * FROM tableCountry WHERE country_name='".$_POST['country']."'";
$resursa = mysql_query($sql);
if (mysql_num_rows($resursa) != 0)
{
$message = "<span class='mesaj3'><li>Error !</span>";
} else {
$sql = "INSERT INTO tableCountry(country_name) VALUES('".$_POST['country']."')";
mysql_query($sql);
$message = "<span class='mesaj4'><li>OK !</span>";
} // end else
} // end else
} else {} // end else
} // end if