jeppers Posted August 21, 2007 Share Posted August 21, 2007 the code below should work but it won't check the password for me. just skips that line and moves to the next one which says that the password has been incorrectly even if it has not <?php // script - login.php // this page lets people log in to the site //address error handling ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); //set the page title and page header define ('TITLE', 'Login'); include ('templates/headder.php'); // basic html formatting stuff print '<div id="leftcontent"> <h1>Login Form</h1> <p>Users who are logged in can take advantage of certain features like this, that, and the other thing.</p>'; //check if the form has been submitted. if (isset ($_POST['submit'])){ //handle the form if ((!empty ($_POST['username']))&&(!empty ($_POST['password'])) ){ if ( ($_POST['username'] == 'j')&&($_POST['password'] == 'p') ){ // okay //redirect the user to the welcom page header ('location: welcom.php'); exit(); }else{//not ok print '<p>The submitted username and password do not match those on file!<br />Go back and try again.</p>'; } }else {//forgot a field. print '<p>Please make sure you enter both a username and a password!<br />Go back and try again </p>'; } }else{ // display the form print '<form action="login.php" method="post"><p> Username: <input type="text" name="username" size="20" /><br /> Password: <input type="password" name="text" size="20" /><br /> <input type="submit" name="submit" value="submit" /><br /> </form>'; }// end of main conditional. //complete the html formatting stuff print '</div>'; include ('templates/footer.php');// need the footer. ?> if you could have a look and see what you think, thank you Quote Link to comment https://forums.phpfreaks.com/topic/65988-solved-another-silly-one/ Share on other sites More sharing options...
MadTechie Posted August 21, 2007 Share Posted August 21, 2007 change Password: <input type="password" name="text" size="20" /><br /> to Password: <input type="password" name="password" size="20" /><br /> EDIT: side note the header ('location: welcom.php'); // will fail as you have already sent data before // basic html formatting stuff print '<div id="leftcontent"> <h1>Login Form</h1> <p>Users who are logged in can take advantage of certain features like this, that, and the other thing.</p>'; Quote Link to comment https://forums.phpfreaks.com/topic/65988-solved-another-silly-one/#findComment-329953 Share on other sites More sharing options...
jeppers Posted August 21, 2007 Author Share Posted August 21, 2007 thanks again Quote Link to comment https://forums.phpfreaks.com/topic/65988-solved-another-silly-one/#findComment-329962 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.