5

Simple login form with php / javascript

 3 years ago
source link: https://www.codesd.com/item/simple-login-form-with-php-javascript.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Simple login form with php / javascript

advertisements

I'm working on a simple login in form that verfies one username and one password using php and javascript. I have a index.php a javascript file to check for errors and a results.php. I can't see anything that I'm doing wrong, but the page continues to submit Invalid login in no matter what is input. Looking for some hints if you guys can give me some. Thanks in advance. I have also looked at similar questions on here and my code pretty much matches the others.

results.php

<?php

$user="joesmith";
$password="abc123";
if(isset($_POST['submit'])){

if(($_POST['user'] == $user) && ($_POST['password'] == $password))
echo "You have successfully logged in";
}
else
{
echo "Invalid login! Try again.";
}
?>

index.php

<body>

<form class="basic-grey" action="results.php" method="post">

<div>
<label for="username" id="lUsernameLabel">* Username:</label>
<input type="text" name="username" id="iUsername"      onblur="validateUserName()" onfocus="resetUserName()" />
<div id="dUsernameError" class="errorMessage"></div>
</div>

<div>
<label for="password" id="lPasswordLabel">* Password:</label>
<input type="password" name="password" id="iPassword"  onblur="validatePassword()" onfocus="resetPassword()" />
<div id="dPasswordError" class="errorMessage"></div>
</div>

<div>
<input type="submit" class="button" value="Submit" />
</div>


your input has name="username" but you are looking for $_POST['user']


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK