Jump to content

katiefox

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

katiefox's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thanks for all your help guys i found the problem by removing this line it all displays correctly, it must have just went through the if(statements) and went straight to this! else { die("Please enter a username and password."); }
  2. hi san4os i have put in your code beingalex as it seams more detailed, now th errors are gone but for some reason the code is going straight to the final else die("please enter username and password") instead of giving me the option to enter a username and password! any ideas guys?! thanks again for the speedy answers
  3. i think that just turns off warnings and errors, which i would prefer to leave on so my code will be good. i did try it and it does stop it but the code does not work it i jumping straight to "Please enter a username and password" at the very end of the if statement. thanks again for your help but this is a college project so the code needs to be correct
  4. hi beingalex, thanks for your help tried that and it got rid of the undefined variable for username but i am still getting undefined index: login?
  5. Hi all this is my first post and im an absolute noob with PHP so be kind! im getting an undefined index error on line 3 for login and an undefined variable: username on line 13 and i cant see why any help would be greatly appreciated. thanks in advance <?php if($_POST['login']) { //get data $username = $_POST['username']; $password = $_POST['password']; $rememberme = $_POST['rememberme']; } //check username and password if($username&&$password) { //set login variable so we can refer back to what the query returns $login = mysql_query("SELECT * FROM lecturer WHERE username='$username'"); //using while loop to make more secure by preventing SQL injection which could be a problem if we chaecked for username AND password while($row = mysql_fetch_assoc($login)) { $user_password = $row['password']; if(($password) == $user_password) $loginsuccess = TRUE; else $loginsuccess = FALSE; //if successful login set cookie or session if($loginsuccess==TRUE) { if($rememberme=="on") setcookie("username", $username, time()+1800); else if($rememberme=="") $_SESSION['username']=$username; header("location: search.php"); exit(); } else die("Incorrect username or password please try again."); } } else { die("Please enter a username and password."); } ?> <br><br><br> <input type="image" src="dculogo.gif"> <br><br><br><br><br> <!-- Create login form Using post to make form more secure --> <form action="login.php" method="post"> Username:<br/> <input type="text" name="username"><p/> Password:<br/> <input type="password" name="password"><p/> <input type="checkbox" name="rememberme">remember me<br/><br/> <input type="submit" name="login" value="Log in" </form>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.