i want to destroy a session by clicking on a link. if i click on that link the session will be destroyed, otherwise not. I don't know the exact code for this, but i have tried with this one :
<?php
echo $sess_destory = "<a href='department.php'> Back </a>";
if($sess_destory)
{
session_destroy();
}
?>
In this way, the session is simply destroying before the time i want. That's why the desired data cannot pass through the other page and showing the error below :
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(id, semester, sem_id) VALUES ('','Second Year First Semester','2-1')' at line 1"
make a generic logout page..
<?
session_start();
session_destroy();
header("location: index.php");
?>
First of all I see a spelling mistake:
if($sess_destory) // should be destroy
{
session_destroy();
}
But, the error you show has to do with an SQL statement
(id, semester, sem_id) VALUES ('','Second Year First Semester','2-1')
Don't know what it should be, but assuming ID is auto incremental, do it this way:
(semester, sem_id) VALUES ("Second Year First Semester","2-1")