Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/65988-solved-another-silly-one/
Share on other sites

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>';

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.