jamesxg1 Posted April 17, 2009 Share Posted April 17, 2009 if (isset($_POST['FileSubmit'])) { $username = mysql_real_escape_string(stripslashes($_POST['username'])); $password = mysql_real_escape_string(stripslashes($_POST['password'])); if (isset($username) && isset($password)) { $result = mysql_query($sql); $sql = sprintf("SELECT * FROM `unlock` WHERE username = '$username' AND password = '$password'") or die(mysql_error()); $result = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($result) > 0) { $morerow = mysql_fetch_array($result); $date = date('Y-m-d'); if ($morerow['when'] == $date) { $_SESSION['username'] = $username; $_SESSION['filename'] = $morerow['filename']; $_SESSION['owner'] = $morerow['owner']; $_SESSION['dir'] = $morerow['format']; header('Location: Main.php'); } else echo "<div align=\"center\"><font color=red> <img src=\"Security/PhotoProcess.php?picname=exclam\"/><i>Your file is unable to be obtained at this present time, Due to the owner specific date being diffrent to today.</i></font></div>"; }else{ echo "<div align=\"center\"><font color=red> <img src=\"Security/PhotoProcess.php?picname=exclam\"/><i>Invalid login<br>If you are a new user please register</i></font></div>"; } }else{ echo "<div align=\"center\"><font color=red> <img src=\"Security/PhotoProcess.php?picname=exclam\"/><i> You must enter a username and password!</i></font></div>"; } } Quote Link to comment https://forums.phpfreaks.com/topic/154498-solved-sessions-not-setting-s/ Share on other sites More sharing options...
Maq Posted April 17, 2009 Share Posted April 17, 2009 What happens, why do you think they're not being set? Do you have session_start() at the top of your script? Quote Link to comment https://forums.phpfreaks.com/topic/154498-solved-sessions-not-setting-s/#findComment-812333 Share on other sites More sharing options...
jamesxg1 Posted April 17, 2009 Author Share Posted April 17, 2009 What happens, why do you think they're not being set? Do you have session_start() at the top of your script? the $username is being set but nothing else :S, and yes i do Quote Link to comment https://forums.phpfreaks.com/topic/154498-solved-sessions-not-setting-s/#findComment-812334 Share on other sites More sharing options...
sloth456 Posted April 17, 2009 Share Posted April 17, 2009 shouldn't you be using mysql_fetch_row instead of mysql_fetch_array? Quote Link to comment https://forums.phpfreaks.com/topic/154498-solved-sessions-not-setting-s/#findComment-812339 Share on other sites More sharing options...
jamesxg1 Posted April 17, 2009 Author Share Posted April 17, 2009 shouldn't you be using mysql_fetch_row instead of mysql_fetch_array? no array is ok as it works in my othe login script which is why im baffeled the othe login script works but this dont but i will get it a go with mysql_fetch_row Quote Link to comment https://forums.phpfreaks.com/topic/154498-solved-sessions-not-setting-s/#findComment-812346 Share on other sites More sharing options...
jamesxg1 Posted April 17, 2009 Author Share Posted April 17, 2009 nope, changing it to mysql_fetch_row creates problems :S, but i am very baffeled here :S Quote Link to comment https://forums.phpfreaks.com/topic/154498-solved-sessions-not-setting-s/#findComment-812352 Share on other sites More sharing options...
Maq Posted April 17, 2009 Share Posted April 17, 2009 So this part sets correctly? And when you echo out $_SESSION['username'] it displays the correct user name from the POST but the other session variables don't echo out anything(aren't set)? $_SESSION['username'] = $username; Where do you actually echo out the session vars to see if they're set? What else outputs? We need some more information. Quote Link to comment https://forums.phpfreaks.com/topic/154498-solved-sessions-not-setting-s/#findComment-812355 Share on other sites More sharing options...
sloth456 Posted April 17, 2009 Share Posted April 17, 2009 perhaps try doing print_r($morerow); just to print out all the items in that array and check they are being pulled from the database. Quote Link to comment https://forums.phpfreaks.com/topic/154498-solved-sessions-not-setting-s/#findComment-812357 Share on other sites More sharing options...
jamesxg1 Posted April 17, 2009 Author Share Posted April 17, 2009 So this part sets correctly? And when you echo out $_SESSION['username'] it displays the correct user name from the POST but the other session variables don't echo out anything(aren't set)? $_SESSION['username'] = $username; Where do you actually echo out the session vars to see if they're set? What else outputs? We need some more information. nothing else outputs none of them are working except the username one, and i print_r the morerow and its all coming back correct :S, no i really confused :S Quote Link to comment https://forums.phpfreaks.com/topic/154498-solved-sessions-not-setting-s/#findComment-812362 Share on other sites More sharing options...
jamesxg1 Posted April 17, 2009 Author Share Posted April 17, 2009 ok iv tryed everything i can now, does anyone know what is going on here :S ? Quote Link to comment https://forums.phpfreaks.com/topic/154498-solved-sessions-not-setting-s/#findComment-812378 Share on other sites More sharing options...
sloth456 Posted April 17, 2009 Share Posted April 17, 2009 how are you checking whether or not the sessions are being set? I would comment out your redirect and echo all the session variables to make sure. Perhaps they're just not being passed correctly in 'main.php' Quote Link to comment https://forums.phpfreaks.com/topic/154498-solved-sessions-not-setting-s/#findComment-812394 Share on other sites More sharing options...
Maq Posted April 17, 2009 Share Posted April 17, 2009 What was the problem? Quote Link to comment https://forums.phpfreaks.com/topic/154498-solved-sessions-not-setting-s/#findComment-812398 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.