Zeradin Posted December 18, 2009 Share Posted December 18, 2009 Hello. I've been making login forms like posting to the same document and then checking everything if the post is submitted and then redirecting. I wanted to make it slicker. I started with this: http://www.developertutorials.com/tutorials/ajax/getting-started-with-ajax-in-jquery-8-05-11/page2.html Tutorial and I can't figure out how to transform this into a session. I can verify that it's correct, but then what? I feel like it's a piece of php programming that after I know how to do it a lot of things will make a lot more sense. Thanks. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 18, 2009 Share Posted December 18, 2009 you should see the variety of session functions you can use to store data http://www.php.net/manual/en/ref.session.php Quote Link to comment Share on other sites More sharing options...
emopoops Posted December 18, 2009 Share Posted December 18, 2009 dont use sesion_register() as it is depresciated and removed in latest php versions Quote Link to comment Share on other sites More sharing options...
Zeradin Posted December 18, 2009 Author Share Posted December 18, 2009 Buuut what I don't get is: <?php $username = $_POST['username']; $password = $_POST['password']; if ($username == "test" && $password == "password") { print "<strong>Login succeeded!</strong>"; HERE I can't start a session and I can't store a session variable and for some reason redirect doesn't work? } else { print "<strong>Login failed! Please try again.</strong>"; } ?> Quote Link to comment Share on other sites More sharing options...
emopoops Posted December 18, 2009 Share Posted December 18, 2009 it works. u must always start the session at the top session_start(); its fine doesnt make anyone logged in then if its ok they logged in with correctnees $_SESSION[username] = $username; now to check if they are logged in if($_SESSION[username] != ""){loged in is what i do Quote Link to comment Share on other sites More sharing options...
Zeradin Posted December 18, 2009 Author Share Posted December 18, 2009 What about the redirect. it just sits on SUCCESSFUL! forever when i insert: <meta http-equiv="Refresh" content="2;url=index.php?p=update"> <br /> <a href="update.php">click here to continue if you are not redirected</a><br /> to the cause. I need it to go somewhere after it is successful. Thanks for the help btw. Quote Link to comment Share on other sites More sharing options...
emopoops Posted December 18, 2009 Share Posted December 18, 2009 whatever. make sure to set a session variable so u can chaeck it later. Quote Link to comment Share on other sites More sharing options...
Zeradin Posted December 18, 2009 Author Share Posted December 18, 2009 no the redirect won't work and so it's kind of useless. It'd be good if it was just something in the top corner but I need it to go to a new page. Quote Link to comment Share on other sites More sharing options...
emopoops Posted December 18, 2009 Share Posted December 18, 2009 my redirect works ){ ?> <a href="http://www.socialemo.com/shilocklipswithpoop.php">click here4 it</a> (if you are not automatically redirected) <meta http-equiv="refresh" content="1;url=http://www.socialemo.com/public/mandatoryapplication.php"> <?php exit();} Quote Link to comment Share on other sites More sharing options...
Zeradin Posted December 18, 2009 Author Share Posted December 18, 2009 That code wasn't working for me but.. Nevermind. Window location fixed it. Thanks. Quote Link to comment Share on other sites More sharing options...
emopoops Posted December 18, 2009 Share Posted December 18, 2009 yw. hope my code gve u it Quote Link to comment 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.