jbingman Posted August 30, 2007 Share Posted August 30, 2007 Hey I'm fairly new to php and i just created a user login page which works. However, I don't know how to get them to a new password requiring page after they press the submit button. How do I go about getting them there? Link to comment https://forums.phpfreaks.com/topic/67376-solved-user-login-page-help/ Share on other sites More sharing options...
madspof Posted August 30, 2007 Share Posted August 30, 2007 Do you mean once they have typed in their details and pressed enter you want the user to be redirected to a page which can only be seen by some one logged in Link to comment https://forums.phpfreaks.com/topic/67376-solved-user-login-page-help/#findComment-338099 Share on other sites More sharing options...
darkfreaks Posted August 30, 2007 Share Posted August 30, 2007 http://www.phpeasystep.com/phptu/21.html easy forgot password tutorial Link to comment https://forums.phpfreaks.com/topic/67376-solved-user-login-page-help/#findComment-338100 Share on other sites More sharing options...
jbingman Posted August 30, 2007 Author Share Posted August 30, 2007 Yeah thats exactly what i want to do. Link to comment https://forums.phpfreaks.com/topic/67376-solved-user-login-page-help/#findComment-338103 Share on other sites More sharing options...
madspof Posted August 30, 2007 Share Posted August 30, 2007 what the tutorial or my suggestion Link to comment https://forums.phpfreaks.com/topic/67376-solved-user-login-page-help/#findComment-338104 Share on other sites More sharing options...
jbingman Posted August 30, 2007 Author Share Posted August 30, 2007 your suggestion..i dont want the forgotten password. just want to know how when they enter their information they get to a page only they can see when they are logged in. Link to comment https://forums.phpfreaks.com/topic/67376-solved-user-login-page-help/#findComment-338108 Share on other sites More sharing options...
madspof Posted August 30, 2007 Share Posted August 30, 2007 Okay well how does your login work. Does it use a db or txt and is it session based or cookie based Link to comment https://forums.phpfreaks.com/topic/67376-solved-user-login-page-help/#findComment-338112 Share on other sites More sharing options...
darkfreaks Posted August 30, 2007 Share Posted August 30, 2007 login tutorial is what you need then http://www.trap17.com/index.php/php-simple-login-tutorial_t7887.html Link to comment https://forums.phpfreaks.com/topic/67376-solved-user-login-page-help/#findComment-338113 Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 You'll need to store something in the session which says they are logged in. On the page, check if the session variable is set. If not, redirect them back to the login screen. Link to comment https://forums.phpfreaks.com/topic/67376-solved-user-login-page-help/#findComment-338114 Share on other sites More sharing options...
darkfreaks Posted August 30, 2007 Share Posted August 30, 2007 jessi that tutorial above me uses sessions Link to comment https://forums.phpfreaks.com/topic/67376-solved-user-login-page-help/#findComment-338115 Share on other sites More sharing options...
jbingman Posted August 30, 2007 Author Share Posted August 30, 2007 what i have right now is... <?php $connect = mysql_connect("localhost","username","password"); $db = mysql_select_db("database"); if(isset($_POST['login'])) { if(mysql_num_rows(mysql_query("SELECT username, password FROM accounts WHERE username = '".$_POST['username']."' && password = '".$_POST['password']."' ")) >0) { if(mysql_num_rows(mysql_query("SELECT id FROM accounts WHERE username = '".$_POST['username']."' && password = '".$_POST['password']."' ")) > 0 ) { $_SESSION['logged'] = true; $_SESSION['username'] = $_POST['username']; $_SESSION['password'] = $_POST['password']; echo "<p style=\"color:green;font-size:12px\">You have successfully logged in!</p>"; }else{ //if the username and password aren't from the same account but does exist echo "<p style=\"color:red;font-size:12px\" align=\"center\"> Incorrect login! Please try again</p>"; } }else{ //username/password doesn't exist echo "<p style=\"color:red;font-size:12px\" align=\"center\">Username/Password doesn't exist!</p>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/67376-solved-user-login-page-help/#findComment-338116 Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 Did you bother to look at the tutorials or research anything we said? Link to comment https://forums.phpfreaks.com/topic/67376-solved-user-login-page-help/#findComment-338117 Share on other sites More sharing options...
darkfreaks Posted August 31, 2007 Share Posted August 31, 2007 Honestly using the session tutorial will teach you alot. Link to comment https://forums.phpfreaks.com/topic/67376-solved-user-login-page-help/#findComment-338126 Share on other sites More sharing options...
jbingman Posted August 31, 2007 Author Share Posted August 31, 2007 Yes, on that one tutorial, trap17, is it possible not to use the register? because i want to be only one user login. Link to comment https://forums.phpfreaks.com/topic/67376-solved-user-login-page-help/#findComment-338128 Share on other sites More sharing options...
darkfreaks Posted August 31, 2007 Share Posted August 31, 2007 $user="abc123" pass="pass" Link to comment https://forums.phpfreaks.com/topic/67376-solved-user-login-page-help/#findComment-338130 Share on other sites More sharing options...
madspof Posted August 31, 2007 Share Posted August 31, 2007 Where you have [echo "<p style=\"color:green;font-size:12px\">You have successfully logged in!</p>";] replace that with header( 'Location: login.html' ) and that will as soon as they have login in redirect you to what ever page you want. <?php $connect = mysql_connect("localhost","username","password"); $db = mysql_select_db("database"); if(isset($_POST['login'])) { if(mysql_num_rows(mysql_query("SELECT username, password FROM accounts WHERE username = '".$_POST['username']."' && password = '".$_POST['password']."' ")) >0) { if(mysql_num_rows(mysql_query("SELECT id FROM accounts WHERE username = '".$_POST['username']."' && password = '".$_POST['password']."' ")) > 0 ) { $_SESSION['logged'] = true; $_SESSION['username'] = $_POST['username']; $_SESSION['password'] = $_POST['password']; echo header( 'Location: login.html' ); }else{ //if the username and password aren't from the same account but does exist echo "<p style=\"color:red;font-size:12px\" align=\"center\"> Incorrect login! Please try again</p>"; } }else{ //username/password doesn't exist echo "<p style=\"color:red;font-size:12px\" align=\"center\">Username/Password doesn't exist!</p>"; } } ?> And then you need to go about creating a page that checks the session to see if they you are logged in which is shown in the tutorials Link to comment https://forums.phpfreaks.com/topic/67376-solved-user-login-page-help/#findComment-338145 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.