Hi
I get users names via $_session variable. for some reason when the user goes to a the a certain page the value which is echoed in a banner on all pages gets lost. The session is still active because if I go to another page that requires the session id to make it work.
complete code
[code=php]
<?php
/* Check User Script */
session_start(); // Start Session
include (“Connections/db.php”);
//check if user is already logged in
if (!isset($_SESSION[‘user_id’])){
$msg = ‘You tryed to access a members only page. Login or become a registered member to access that page!’;
header(“Location: ../index.php?msg=”.$msg);
}
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Buddy List</title>
<link rel=”stylesheet” type=”text/css” href=”design/niftyCorners.css”>
<link rel=”stylesheet” type=”text/css” href=”design/niftyPrint.css” media=”print”>
<script type=”text/javascript” src=”design/nifty.js”></script>
<link href=”design/main.css” rel=”stylesheet” type=”text/css” />
<script type=”text/javascript”>
window.onload=function(){
if(!NiftyCheck())
return;
<?php include(‘design/round.php’); ?>
}
</script>
</head>
<body>
<div id=”outer”>
<?php include(‘design/banner.php’); ?>
<div id=”twoColumnRight”>
<?php
if(isset($_REQUEST[‘msg’])){
echo ‘<div id=”formmessage”>’;
echo ‘<p style=”margin-left:40px;”>’.$_REQUEST[‘msg’].'</p>’;
echo ‘</div>’;
}
?>
<?php
for ($x=65; $x<=90; ++$x):
echo ‘ <a href=”mybuddies.php?index=’ .chr($x). ‘”>’ .chr($x). “</a>n”;
endfor;
echo ‘ <a href=”mybuddies.php?index=*”>ALL’.”</a>n”;
echo ‘<br />’;
echo ‘<br />’;
if($hide == “”){
echo ‘<a href=”mybuddies.php?hide=hide”>Find Buddy / Export</a>’;
}
if($hide == “hidden”) { ;
echo ‘<a href=”mybuddies.php?hide=hide”>Find Buddy / Export</a>’;
}
?>
<?php if($hide == “hide”) { ;
echo ‘<a href=”mybuddies.php?hide=hidden”>Find Buddy / Export</a>’;
?>
<form name=”searchforBuddy” method=”post” action=”Scripts/codesearch.php”>
<table class=”columntable” cellspacing=”2″ style=”width:80%;”>
<tr><td class=’tableheader’ colspan=’2′>Search for Buddies</td></tr>
<tr>
<td class=”rowLeft”><strong>First Name*</strong></td>
<td class=”rowRight”><input name=”s_firstname” type=”text” id=”s_firstname” size=”25″ /></td>
</tr>
<tr>
<td class=”rowLeft”><strong>Last Name*</strong></td>
<td class=”rowRight”><input name=”s_lastname” type=”text” id=”s_lastname” size=”25″ /></td>
</tr>
<tr>
<td colspan=”2″ class=”rowRight”><p>Click Icon to Export Address Book to <span class=”BorderGreenXbg”> Excel.The file name will be "buddList" with the current date at the end. Downloaded the file today ane the name would be <b>buddylist<? echo date(“Y-m-d”); ?>.xls</b></span></p>
<a class=”rowRight” href=”exportExcel.php” title=”Export Address Book”><img src=”images/excellogo.jpg” alt=”excelLogo” /></a></td>
</tr>
<tr>
<td colspan=”2″>
<input type=”submit” name=”Submit” value=”Submit” />
</td>
</tr>
</table>
</form>
<?php } ?>
<?
$active_id = $_SESSION[‘user_id’];
$buddy_id = $_POST[‘addbuddy’];
$array = explode(“,”,$buddy_id);
$post_b_id = $array[0];
$first_name = $array[1];
$last_name = $array[2];
$sql_buddy_check = mysql_query(“SELECT * FROM buddylink WHERE owner_id=’$active_id’ AND buddy_id =’$post_b_id'”);
$buddy_check = mysql_num_rows($sql_buddy_check);
if($buddy_check > 0){
echo $first_name. ‘ ‘ . $last_name. ” was found in your buddy list <br>”;
echo “<a href=javascript:history.back()>Go Back</a>”;
exit ();
}
if($buddy_id != “”){
// ADD TO TABLE
$sql = mysql_query(“INSERT INTO buddylink (owner_id, buddy_id, first_name, last_name, added)VALUES(‘$active_id’, ‘$post_b_id’, ‘$first_name’, ‘$last_name’, now())”)or die (“Link Create Error:” .mysql_error());
}
if($d_buddy != “”){
mysql_query(“DELETE FROM buddylink WHERE buddy_id = ‘$d_buddy'”);
}
$query = mysql_query(“SELECT * FROM buddylink WHERE owner_id =’$active_id’ AND status = ‘2’”) or die (“Search Error” .mysql_error());
while($r=mysql_fetch_assoc($query)) {
$buddy_user_id = $r[‘buddy_id’];
$b_id = $r[‘buddy_id’];
$index = strtoupper(substr($_GET[‘index’],0,1));
if($index != ‘*’ && (ord($index) < 65 || 90 < ord($index))) $index = ‘*’;
if($index == ‘*’) $get_buddy_info = mysql_query(“Select * From `users` WHERE user_id = ‘$buddy_user_id'”);
else $get_buddy_info = mysql_query(“Select * From `users` Where `last_name` Like ‘{$index}%’ AND user_id = ‘$buddy_user_id'”);
while($buddy_info_r=mysql_fetch_assoc($get_buddy_info)) {
$email = $buddy_info_r[’email_address’];
echo “<div class=”buddygifts”>”;
echo “<p class=’cardheader’><a href=’SearchDetails.php?owner_id=$b_id’><div class=”tableheader”>”.$buddy_info_r[‘last_name’].’,’.$buddy_info_r[‘first_name’].”</div></a></p>”;
echo “<p>”.$buddy_info_r[‘street_address’].”<br/>”. $buddy_info_r[‘post_office_box’]. ‘ ‘.$buddy_info_r[‘city’]. ‘ ‘.$buddy_info_r[‘province’].’ ‘.$buddy_info_r[‘postal’].”</p>”;
echo “<p>Phone: “.$buddy_info_r[‘home_phone’].”</p>”;
echo “<p><a href=’sendEmail.php?email=$email’>”.$buddy_info_r[’email_address’].”</a></p>”;
//get icons
$get_wish_query = mysql_query(“SELECT * FROM wishlist WHERE owner_id =’$b_id'”) or die (“Search Error” .mysql_error());
$wish_query = mysql_num_rows($get_wish_query);
if($wish_query >0){
echo “<p><a class=’emailBullet’ href=’../wishlist/buddywishlist.php?wish=$b_id’><img src=’images/gift.jpg’ alt=’gift’ title=’Go to buddies gift list’></a>”;
}else{
}
// check if found user has a photo ablum
$photoCheck = mysql_query(“SELECT * FROM images WHERE owner_id = ‘$b_id'”)or die(mysql_error());
$photo_find = mysql_num_rows($photoCheck);
if($photo_find >0){
echo “<a class=’emailBullet’ href=’photos/usersPhotoAlbum.php?owner_id=$b_id’><img src=’images/camera.jpg’ alt=’cameraBullet’ title=’See Buddies Photos’></a></p>”;
}else{
}
echo “<form name=’dBuddy’ method=’post’ action=’mybuddies.php?buddy_id=$b_id’>”;
echo “<input type=’submit’ name=’deletebuddy’ value=’Del’>”;
echo “</form>”;
echo “</div>”;
}
}
echo “<div class=”clear”></div>n”;
?>
</div>
<div id=”twoColumnLeft”>
<?php include(‘design/leftlinks.php’); ?>
</div>
<div id=”footer”>
<?php include(‘design/footer.php’); ?>
</div>
</div>
</body>
</html>