dalerex Posted January 27, 2009 Share Posted January 27, 2009 Hi All, I was wondering if anyone here can help me out. I'm in the process of creating a simple social networking website with some very basic code. I'm currently stuck at a point where if my users log in, I am not able to pass their credentials from one page to another. The session doesn't pass properly. I have attached the codes for your review. Please let me know what I'm doing wrong. Any and all help is appreciated. Thanks, dalerex [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
MP145 Posted January 27, 2009 Share Posted January 27, 2009 You can try removing the caps <HTML> tag on member-profile.php. You already have a tag above that line. <html xmlns="http://www.w3.org/1999/xhtml"> <HTML> // you can remove this. and also try adding <?php session_start(); ?> on top of your member-profile.php page Ex: <?php session_start(); ?> <!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>Strike A Style.com - My Profile</title> Try it out. Regards, Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted January 27, 2009 Share Posted January 27, 2009 yes you need to start your session or verify your php.ini is autostarting the sessions the session_start(); needs to be declared before any browser output is sent otherwise it can not grab the session data. Quote Link to comment Share on other sites More sharing options...
dalerex Posted February 3, 2009 Author Share Posted February 3, 2009 hi guys, thanks for the help so far. i've tried the above suggestions but it unfortunately did not work. any other things i should try? thanks. Quote Link to comment Share on other sites More sharing options...
ngreenwood6 Posted February 3, 2009 Share Posted February 3, 2009 Shouldn't this: //Check whether the query was successful or not if($result) { if(mysql_num_rows($result) == 1) { //Login Successful session_regenerate_id(); $member = mysql_fetch_assoc($result); $_SESSION["member_id"] = $member_id; $_SESSION["firstname"] = $firstname; $_SESSION["lastname"] = $lastname; $_SESSION["login"] = $login; $_SESSION["sex"] = $sex; $_SESSION["month"] = $month; $_SESSION["day"] = $day; $_SESSION["city"] = $city; $_SESSION["country"] = $country; header("location: profile.php?id=$login"); exit(); Be this: //Check whether the query was successful or not if($result) { if(mysql_num_rows($result) == 1) { //Login Successful session_regenerate_id(); $member = mysql_fetch_assoc($result); $_SESSION["member_id"] = $member['member_id']; $_SESSION["firstname"] = $member['firstname']; $_SESSION["lastname"] = $member['lastname']; $_SESSION["login"] = $member['login']; $_SESSION["sex"] = $member['sex']; $_SESSION["month"] = $member['month']; $_SESSION["day"] = $member['day']; $_SESSION["city"] = $member['city']; $_SESSION["country"] = $member['country']; header("location: profile.php?id=$login"); exit(); In the future just post the code that you are having problems with. Also, you need to say more than it didn't work. you need to tell us what didn't work, if you got any errors, etc. All I did there was change the sessions to get the data from the database. An easier was to see if your values are getting set is to just echo them to make sure. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.