tomfmason Posted July 8, 2006 Share Posted July 8, 2006 I am attempting to create a login script and hide the login process. I have tried a number of things and have yet to get it worked out. The way that I am trying now is having the form post to it's self. I have searched and read the manual but it is rather vague on this subject. The problem that I am running into, with the code posted below, is that when I try to login the form is just reloaded. The login is not processed. [b]Here is the code[/b][code]<?phpsession_start();include('includes/db.php');if (isset($_POST['submit'])) {$sql_user_check = "SELECT username FROM users WHERE username='$username'";$result_name_check = mysql_query($sql_user_check) or die(mysql_error());$usersfound = mysql_num_rows($result_name_check) or die(mysql_error());if ($usersfound < 1){ $error = "User ".$username." was not found in the database."; $username = $_POST['username']; $password = md5($_POST['password']); $sql = "select * from users where `username` = '$user'"; $result = mysql_query($sql); while ($text = mysql_fetch_array($result)) { $id = $text['id']; $password = $text['encrytpass']; $access = $text['access']; } if ($pass == $password) { $error = "Wrong Username / Password <a href=\"../index.php\">Back</a>"; }else{ $_SESSION['username'] = $user_info['username']; }}if(!$_SESSION['username']){ if($error){ echo $error; include("index.php"); }else{ echo "You are logged in."; include("index2.php"); } }else{ echo "<html><head><title>Welcomce Back</title></head>Welcome back ". $_SESSION['username'] .".<a href=index2.php>Click here</a> to proceed."; }} $filename = "login.php";$title = "Login";$content= " <form action=\"test_login3.php\"; method=\"post\"> <label>   login</label> <p>    <input type=\"text\" name=\"username\" size=\"20\" maxlength=\"15\" value=\"username\"> </p> <p>    <input type=\"password\" name=\"password\" size=\"20\" maxlength=\"15\" value=\"password\"> </p> <p>    <input name=\"goButton1\" type=\"submit\" value=\"go\" alt=\"go\"> </p> </form>";include('includes/main.php'); ?>[/code][b]A little explanation of the code[/b]At the beginning I call for the session_start() and then proceed through the standard check process-[i]This is were, I am sure, that the problem begins.[/i]after the login I call for the login form[code] $filename = "login.php";$title = "Login";$content= " <form action=\"test_login3.php\"; method=\"post\"> <label>   login</label> <p>    <input type=\"text\" name=\"username\" size=\"20\" maxlength=\"15\" value=\"username\"> </p> <p>    <input type=\"password\" name=\"password\" size=\"20\" maxlength=\"15\" value=\"password\"> </p> <p>    <input name=\"goButton1\" type=\"submit\" value=\"go\" alt=\"go\"> </p> </form>";include('includes/main.php');[/code]Am I going about this the right way?Any suggestions would be great. Quote Link to comment https://forums.phpfreaks.com/topic/13996-questions-about-isset/ Share on other sites More sharing options...
Kurt Posted July 8, 2006 Share Posted July 8, 2006 Im just going to take a wild guess because I dont feel like reading all that code, but you could try !empty() instead of isset() because isset() will return true even if it returns en empty string. Quote Link to comment https://forums.phpfreaks.com/topic/13996-questions-about-isset/#findComment-54662 Share on other sites More sharing options...
Crimpage Posted July 8, 2006 Share Posted July 8, 2006 And just past that on this line[code]$sql_user_check = "SELECT username FROM users WHERE username='$username'";[/code]Where has $username been defined? It is defined later, but not before that line. Quote Link to comment https://forums.phpfreaks.com/topic/13996-questions-about-isset/#findComment-54682 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.