Sure enough when i edit the post saying the header includes the database information.. i double check it and its not there
I guess i have another question... How to i get it to show information about the session (ie username, email, name, etc)? My login has session_register('fullname'); $_SESSION['fullname'] = $row['fullname']; PHP: for all the things i want, and then i put <? $_SESSION['fullname']; ?> PHP: where I want it to display but it just comes up blank. (i am starting the session) Also, how do i end a session? I try: <? session_start(); session_destroy(); ?> PHP: But i am still logged in.
tried with and without echo, still doesnt show anything. and what do you mean by "And session_register() is deprecated."? Thanks.. +rep Just wanted to make it clear session_register('fullname'); $_SESSION['fullname'] = $row['fullname']; PHP: is on the login.php page, do i need to transfer this to all pages that require a session? Heres my full login.php: <? include'inc/header.php'; ?> <div id="home"> <b>Please Login</b> <hr noshade> <p> <center> <? if(session_id()!=''){ echo'Your already logged in.'; }else{ ?> <? if($_GET['i'] == "2") { $email = stripslashes($_POST['email']); $password = md5(stripslashes($_POST['password'])); $sql = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$password'"); $login_check = mysql_num_rows($sql); if($login_check > 0){ while($row = mysql_fetch_array($sql)){ $_SESSION['fullname'] = $row['fullname']; $_SESSION['address1'] = $row['address1']; $_SESSION['address2'] = $row['address2']; $_SESSION['city'] = $row['city']; $_SESSION['state'] = $row['state']; $_SESSION['country'] = $row['country']; $_SESSION['email'] = $row['email']; $_SESSION['paypal'] = $row['paypal']; $_SESSION['offers'] = $row['offers']; $_SESSION['completedoffers'] = $row['completedoffers']; $_SESSION['pendingoffers'] = $row['pendingoffers']; $_SESSION['pendingbalance'] = $row['pendingbalance']; $_SESSION['balance'] = $row['balance']; mysql_query("UPDATE members SET lastlogin=now() WHERE email='$email'"); echo'Login Successful'; } }else{ echo 'The information you entered is not correct.'; } }else{ ?> <form action="login.php?i=2" method="POST"> Email<br /> <input size="20" type="text" name="email" class="signup"> <br /> Password<br /> <input size="15" type="password" name="password" class="signup"> <br /><br /> <input type="submit" value="Login"> </form> <? } } ?> </center> </p> </div> <? include'inc/footer.php'; ?> PHP: And heres a page where I want to show data from the session: <? include'inc/header.php'; ?> <div id="home"> <? if(session_id()!=''){ ?> <? include'inc/menu.php'; ?><br /> <hr noshade> <br /> Full Name: <? $_SESSION['fullname']; ?> <br /> Address 1: <? $_SESSION['address1']; ?> <br /> Address 2: <? $_SESSION['address2']; ?><br /> City: <? $_SESSION['city']; ?><br /> State: <? $_SESSION['state']; ?><br /> Country: <? $_SESSION['country']; ?><br /> Zip Code: <? $_SESSION['zip']; ?><br /> <br /> <br /> <input type="submit" value="Change"> <? }else{ echo'Your Not Logged In.'; } ?> </div> <? include'inc/footer.php'; ?> PHP: The header file contains the session_start(); and db information.
You need to make your header.php code like so: <? ob_start(); session_start(); include'inc/db.php'; --other stuff-- ?> PHP: Make sure that ob_start(); is at the beginning of the document, no matter what. That should make it work. ***By the way, make sure you go into your footer.php and put in ob_end_flush(); at the very bottom, so it shuts that all down.
i fixed it... I added $_SESSION['login'] = true; to the login page, and i changed if(session_id()!='') to if($_SESSION['login']) I just have one question, would doing "$_SESSION['login'] = true;" limit the number of people who can be online at a time?