provision Posted June 30, 2008 Share Posted June 30, 2008 Hi i got this page im working on for fun and I had it loggig in and the sessions working properly then it just stopped. heres the code db_connect(); session_start(); $name = $_POST["name"]; $direc = $_POST["director"]; $age = $_POST["age"]; $genre = $_POST["genre"]; $user = $_POST["username"]; $password = $_POST["password"]; if(isset($_SESSION["loggedin"])) { print'<form method="post" action="admin.php"> <fieldset> <label for="name" id="name">Title:</label> <input type="text" name="name" /> <label for="director" id="director">Director:</label> <input type="text" name="director" /> <label for="genre" id="genre">Genre:</label> <input type="text" name="genre" /> <label for="age" id="age">Age:</label> <select name="age"> <option value="new">New</option> <option value="recent">Recent</option> <option value="old">Old</option> </select> <label></label> <input type="submit" name="submit" value="Submit" class="submit-button" /> </fieldset> </form>'; if($_POST["name"] != "") { $sql = "insert into movies (movie_name, movie_director, genre, age) values ('$name','$direc','$genre','$age') "; mysql_query($sql); print"Success!"; } } else { print'<form method="post" action="admin.php"> <fieldset> <label for="username" id="name">Username:</label> <input type="text" name="username" /> <label for="password" id="director">Password:</label> <input type="password" name="password" /> <label></label> <input type="submit" name="submit" value="Submit" class="submit-button" /> </fieldset> </form>'; $pass = crypt($password, chicken); if($_POST["username"] != "") { $sql = "select * from user where username = '$user' and password = '$pass'"; $r = mysql_query($sql); if(mysql_affected_rows()==0) { print"Invalid user or pass!"; print"$user, $pass"; } else { session_register('loggedin'); print"Session set!"; } } } ?> Thanks Quote Link to comment https://forums.phpfreaks.com/topic/112668-session-wont-register/ Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 put session_start(); before db_connect(); ACE Quote Link to comment https://forums.phpfreaks.com/topic/112668-session-wont-register/#findComment-578621 Share on other sites More sharing options...
.josh Posted June 30, 2008 Share Posted June 30, 2008 put session_start(); before db_connect(); ACE Unless he's trying to utilize session vars in db_connect(); that doesn't really matter. All that really matters is that you have it before any output and before trying to utilize session vars. Hi i got this page im working on for fun and I had it loggig in and the sessions working properly then it just stopped. You're going to have to be more specific than that. Trying to navigate to another page and there's no session? Could mean that you don't have session_start(); at the new page. session_start(); must be on any page you wish to have access. If you do have that squared away, do you have cookies enabled? If you do not have cookies enabled, the server has no idea what your session id is, so it can't access your session data. If you have that squared away, be more specific about your problem. Any error messages? At what point does it "stop working," and what does that mean? Blank values? Again, be more specific about your problem. Quote Link to comment https://forums.phpfreaks.com/topic/112668-session-wont-register/#findComment-578629 Share on other sites More sharing options...
provision Posted June 30, 2008 Author Share Posted June 30, 2008 HI sorry for leaving stuff out Everything goes on in this one admin page, you login and if there is a valid session i want it to show the other form not the login one. Umm yer cookies are enabled. No error messages it i put this into the section for setting session print"Session set!"; and it says that so i dont know why it is not setting the session. Well it was working unitl i tryed to make a logout page. when it stopped working i deleted that page and re wrote the admin one and it still didnt work..... Quote Link to comment https://forums.phpfreaks.com/topic/112668-session-wont-register/#findComment-578636 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.