0

I just started getting into php recently and I wanted to create a simple login with(out any SQL (haven't learned it yet :$). So Here is my code for login page:

<form action="index.php" method="post">
			Username<input type="text" name="user" /> <br />
			Password<input type="password" name="pass" /> <br />
			<input type="submit" />
		</form>

	<?php
		$username = username;
		$password = password;
		
		$iusername = $_POST["user"];
		$ipassword = $_POST["pass"];
		
		if ($username==$iusername && $password==$ipassword) {
			include('../0340791aacd04a07560cd7dc983ed98e.php');
		}else{
			echo 'Incorrect pass';
		}
	?>

Now the problem is,

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Stefano Mtangoo
0

hmm

<form action="index.php" method="post">
    Username <input type="text" name="username" /> <br />
    Password<input type="password" name="password" /> <br />
    <input type="submit" />
</form>
     
<?php
$iusername = 'user';
$ipassword = 'pass';

$username = $_POST["username"];
$password = $_POST["password"];

if(!$username && !$password)
{
	echo 'No sign in name entered or password';
}
else if($username == $iusername && $password == $ipassword)
{
	include('./0340791aacd04a07560cd7dc983ed98e.php');
	echo '=)';
}
else
{
	echo 'Incorrect pass';
}
?>
0

Oops! Forgot to finish the thread. The problem is, It says "Incorrect password" even on the first load (when someone goes to the page, and doesnt even type a username/pass). I get why this is happening. How can I make it so it only says "incorrect pass" after 1 attempt? Not just when there is no information sent through $_POST?

0
<?php

$form = <<<EOT
<form action={$_SERVER["PHP_SELF"]} method="post" enctype="multipart/form-data">
    <label for="username">Username:</label>
    <input type="text" name="username" />
    <br /><br />
    <label for="password">Password:</label>
    <input type="password" name="password" />
    <br />
    <input type="submit" name="submit" value="Submit" />
</form>

EOT;

if(isset($_POST['submit'])){
//do stuffs
print_r($_POST);

}else{
 echo $form;
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.