session not destroyed?????
Posted: Sat Aug 28, 2010 12:41 am
friends
on a single form i have to submit the posted data into the database......for that i m using validateInput(); function
once the function return validated my data goes to the table it show the message "Data entered succesfully". when i click OK and refresh the same page , same data will insert again. I have used the session_unset(); but this also not working
thank you
on a single form i have to submit the posted data into the database......for that i m using validateInput(); function
Code: Select all
function validateInput()
{
if($error==0 && trim($_POST['name']) == "")
{
return "Please enter student name.";
$error=1;
}
if($error==0 && trim($_POST['id']) == "")
{
return "Please enter student ID.";
$error=1;
}
return "validated";
}
Code: Select all
$isError = validateInput();
if($isError=="validated")
{
$query = "INSERT INTO `software` (`SNO`,`NAME`, `ID`, `HOSTEL`, `SOFTWARE`, `URL`, `SIZE`) VALUES ('$sno','$name', '$id', '$hostel', '$software', '$url','$size')";
$result = mysql_query($query) or die ("Error in query: $query<br/>");
if($result)
{
print '<script>alert("Data entered succesfully")</script>';
$done=true;
session_unset();
session_destroy();
$sno++;
}
}
else
{
echo "<br><center><font color='red'>$isError</font></center>";
}