Jragon Posted July 22, 2010 Share Posted July 22, 2010 My session is not working for somereaseon My index code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>VisualUpload Share what you see</title> </head> <body bgcolor="#f1f1f1" text="#000000" link="33cc00" vlink="33cc00" alink="33cc00"> <table align="center" width="95%" bgcolor="#ffffff" style="border-color: #999999; border-style:solid;border-width:1px" border="0"> <tr> <td> <table> <tr> <td width="50%"> <img src="images/logo.png" /> </td> <td> <form method="post" action="login.php" > <table width="100%"> <tr> <td> Username: </td> <td> <input type="text" name="user" size="16" maxlength="25"/> <a href="register.php">Register</a> </td> </tr><tr> <td> Password: </td> <td> <input type="password" name="pass" size="16" maxlength="25"/> <input type="submit" value="Log in"/> </td> </tr> </table> </form> </td> </tr> </table> <?php if (isset($_SESSION['user'])){ echo '<tr> <td> <table width="100%"> <tr> <td width="20%" valign="top"> <font size="4"> <a href="upload.php"><strong>Upload</strong></a><br /> <a href="albums.php"><strong>Albums</strong></a><br /> <a href="profile.php"><strong>Profile</strong></a><br /> </font> </td> <td valign="top"> <font size="4"> <b>Recant Images</b><br /> <font size="2"> You Haven\'t uploaded any picturs!<br /> </font> </font> <font size="4"> <b>Recant Videos</b><br /> <font size="2"> You Haven\'t uploaded any videos!<br /> </font> </font> </td> </tr> </table> </td> </tr>'; } ?> </td> </tr> </table> </body> </html> my login code: <?php session_start; include("getsalt.php"); require("connect.php"); include("getname.php"); $post_username = $_POST['user']; $post_password = $_POST['pass']; if (isset($post_password) && isset($post_username)){ if(strlen($post_username)>25||strlen($post_password)>25){ die('Username or password character length too long!'); }else{ //convert pass to md5 $salt = getsalt($post_username); $post_password = md5($salt.$post_password); $login = sprintf("SELECT * FROM user WHERE username='%s' AND password = '%s'", mysql_real_escape_string($post_username), mysql_real_escape_string($post_password)); $rowcount = mysql_num_rows(mysql_query($login)); if ($rowcount == 1){ $_SESSION['user'] = $post_username; $name = getname($post_username); echo 'Welcome ' . $name . '!<br /> Please click <a href="index.php">here</a> to go back to the main page.'; } } }else{ die('Please enter a useranme and password'); } ?> Please help Thanks Jragon Quote Link to comment https://forums.phpfreaks.com/topic/208535-my-session-is-not-working/ Share on other sites More sharing options...
bh Posted July 22, 2010 Share Posted July 22, 2010 Any error? Anyway not session_start its session_start() . Before you use any $_SESSION variable, you have to call session_start() . Quote Link to comment https://forums.phpfreaks.com/topic/208535-my-session-is-not-working/#findComment-1089543 Share on other sites More sharing options...
timvdalen Posted July 22, 2010 Share Posted July 22, 2010 Try printing the session vars with print_r to see if anything happens at all. Also, what's with the turtle logo? EDIT: Oh, yeah, that's (^) what's wrong. Didn't even notice that. Are you sure you have error reporting on? Quote Link to comment https://forums.phpfreaks.com/topic/208535-my-session-is-not-working/#findComment-1089544 Share on other sites More sharing options...
timvdalen Posted July 22, 2010 Share Posted July 22, 2010 Oh, and btw. When I try to log in with the login info you dumped in one of your other thread, MySQL denies anthony@localhost Quote Link to comment https://forums.phpfreaks.com/topic/208535-my-session-is-not-working/#findComment-1089545 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.