I have implemented a log-in routine that I thought captured SESSION variable to use through out all my PHP pages of my site. Here is the snippet of code which sets the session variables:
if($result) {
if(mysql_num_rows($result) == 1) {
//Login Successful
session_regenerate_id();
$member = mysql_fetch_assoc($result);
$_SESSION['SESS_MEMBER_ID'] = $member['id'];
$_SESSION['SESS_FIRST_NAME'] = $member['First_Name'];
$_SESSION['SESS_LAST_NAME'] = $member['Last_Name'];
$_SESSION['SESS_ADMIN'] = $member['ADMIN'];
session_write_close();
header("location: Service_Dates.php");
exit();
}else {
//Login failed
header("location: login-failed.php");
exit();
}
}else {
die("Query failed");
}
On one of my pages, I am trying to see if the current logged in user is a volunteer who has already been signed up for a particular Event Date. Here is the code:
<?
// Check to see if Logged In Volunteer is already in the signed up
$id_User = $_SESSION['SESS_MEMBER_ID'];
$query2 = "select * FROM Ev_AvVolunteers where id_Event='$id_Event' and id_Volunteer='$id_User'";
Print_r($query2);
//exit();
$results2 = mysql_query($query2) or die("Error performing query");
if ( $results2 ) { ?>
echo "<div align="left"><span class="style14">Remove Me<br />- <br />";
<? } else { ?>
echo "<div align="left"><span class="style14">Add Me<br />- <br />";
<? } ?>
Shouldn't this grab my SESSION MEMBER ID?
My goal is to display a "Add Me" or "Remove Me" based on if they exist in the table.
Thanks ;-)