blufish Posted May 31, 2008 Share Posted May 31, 2008 Okay, so I have a site where I am currently making a sign-up / sign-in thing, the signup works great! but the sign in has difficulties, I try to save to the the variable $_SESSION['user'] in the login screen then read it on other pages. Any ideas why this is not working? Login Page: <?php $name = strip_tags($_POST[name]); $nc = strtolower($name); if (!file_exists("check".$nc)) { echo "<h1 align=center>Account does not exists!</h1>"; } if (file_exists($name)) { $pass = strtolower($_POST['pass']); $pass = str_replace("a","[1]",$pass); $pass = str_replace("b","[2]",$pass); $pass = str_replace("c","[3]",$pass); $pass = str_replace("d","[4]",$pass); $pass = str_replace("e","[5]",$pass); $pass = str_replace("f","[6]",$pass); $pass = str_replace("g","[7]",$pass); $pass = str_replace("h","[8]",$pass); $pass = str_replace("i","[9]",$pass); $pass = str_replace("j","[10]",$pass); $pass = str_replace("k","[11]",$pass); $pass = str_replace("l","[12]",$pass); $pass = str_replace("m","[13]",$pass); $pass = str_replace("n","[14]",$pass); $pass = str_replace("o","[15]",$pass); $pass = str_replace("p","[16]",$pass); $pass = str_replace("q","[17]",$pass); $pass = str_replace("r","[18]",$pass); $pass = str_replace("s","[19]",$pass); $pass = str_replace("t","[20]",$pass); $pass = str_replace("u","[21]",$pass); $pass = str_replace("v","[22]",$pass); $pass = str_replace("w","[23]",$pass); $pass = str_replace("x","[24]",$pass); $pass = str_replace("y","[25]",$pass); $pass = str_replace("z","[26]",$pass); if (file_exists($pass."+%+".$nc)) { $time = time()+(3600*24*365); $_SESSION['user'] = $_POST['name']; } if (!file_exists($pass."+%+".$nc)) { echo "Username and password do not match!"; } } ?> Page that attempts to see if someone is logged in: <html> <head> <?php ini_set('error_reporting',E_ALL); //error reporting if ($_GET['where']=='jokes/blond') { echo "<TITLE>Frozenoven :: Jokes :: Dumb Blonde Jokes</TITLE>"; } if ($_GET['where']=='home') { echo "<TITLE>Frozenoven :: Home</TITLE>"; } if ($_GET['where']=='customize') { echo "<TITLE>Frozenoven :: Customization</TITLE>"; } if ($_GET['where']=='jokes/yourmother') { echo "<TITLE>Frozenoven :: Jokes :: Your Mother Jokes</TITLE>"; } if ($_GET['where']=='jokes/6yroldbacktalk') { echo "<TITLE>Frozenoven :: Jokes :: 6-Year-Old-Back-Talk</TITLE>"; } if (isset($_SESSION['user'])) { echo '<link rel="stylesheet" type="text/css" href="'.$_SESSION['user'].'">'; } else { echo '<link rel="stylesheet" type="text/css" href="white.css">'; } ?> <script type="text/javascript"> function go(location) { parent.location = location } </script> </head> <body> <?php if (isset($_SESSION['user'])) { echo 'Hey "'.$_SESSION['user'].'"! <a href=logout.php>Logout</a>'; } else { echo "Hey Guest! <a href='http://www.frozenoven.com/index.php?where=make'>wanna customize?</a>"; } ?> <center> <table> <tr> <td align=center> <img src="http://www.frozenoven.com/images/logo.gif" width="500" height="53.7" alt="www.frozenoven.com"> </td></tr> <tr> <td><table><tr> <td width=100 valign=top> <div class="side"><p class="option"><a href="http://www.frozenoven.com/index.php?where=account">Accounts</a></p></div> <div class="side"><p class="option"><a href="http://www.frozenoven.com/index.php?where=jokes/index">Jokes</a></p></div> </td><td valign=top> <div class="main"><p> <?php $mypage = $_GET['where']; $mypage = $mypage.".fzp"; if ($mypage==".fzp") { echo "<script type='text/javascript'>parent.location='http://www.frozenoven.com/index.php?where=home';</script>"; } if (file_exists($mypage)) { echo file_get_contents($mypage); } if (!file_exists($mypage)) { echo "<h1 align=center>404 File not Found!</h1><p>Either the file you are looking for does not exist or you typed the url wrong.</p><p align=center><a href='http://www.frozenoven.com'>Home</a>"; } ?></p></div> </td> </tr> </table> </td> </tr> </table> <table> <tr> <td> <div class="ad"> <script type="text/javascript"><!-- google_ad_client = "pub-2142734016668784"; /* 728x90, created 5/30/08 */ google_ad_slot = "1701812294"; google_ad_width = 728; google_ad_height = 90; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> </td> </tr> </table> </center> </body> </html> if you want to see what happens: mess around: http://www.frozenoven.com/index.php thanks in advance Link to comment https://forums.phpfreaks.com/topic/108089-solved-problem-with-logins/ Share on other sites More sharing options...
beboo002 Posted May 31, 2008 Share Posted May 31, 2008 you need to start session in every page where u session access or created put this line on the top of page <? session_start();?> Link to comment https://forums.phpfreaks.com/topic/108089-solved-problem-with-logins/#findComment-554039 Share on other sites More sharing options...
beboo002 Posted May 31, 2008 Share Posted May 31, 2008 why u post same question with different title ur last topic is http://www.phpfreaks.com/forums/index.php/topic,199706.0.html and first u check ur $_POST[name];echo it Link to comment https://forums.phpfreaks.com/topic/108089-solved-problem-with-logins/#findComment-554048 Share on other sites More sharing options...
blufish Posted May 31, 2008 Author Share Posted May 31, 2008 My apologies about the double post, I was sort of rewording the question, cause I was changing it a lot. Thank you for the help, it is working now. Link to comment https://forums.phpfreaks.com/topic/108089-solved-problem-with-logins/#findComment-554056 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.