How do I get information from html page with javascript to php? I hardcode my userid and password but it cant work...
Javascript:
<script type="text/javascript">
var user = ["jack", "james", "lisa"];
var pass = ["jack123", "james123", "lisa123"];
function login() {
var uid = document.getElementById("uid").value;
var pin = document.getElementById("PIN").value;
if (uid == user[0] && pin == pass[0] || uid == user[1] && pin == pass[1] || uid == user[2] && pin == pass[2]){
alert("Log in Successful");
window.location.href = "Welcom(withdrawal).php" ;
}
else{
alert("Your User ID and PIN do not match!");
return false;
}
}
</script>
Form:
<section class="right" >
<table bgcolor="#FFFFFF" border="0" >
<form method="post" onsubmit="login();return false;" >
<caption id="sidehead">Finger-Print banking</caption>
<tr>
<td>
<label for="uid" >User ID :</label>
<input class="row2" type="text" tabindex="1" maxlength="20" size="20" name="uid" id="uid">
</td>
</tr>
<tr>
<td>
<label for="PIN" >PIN :</label>
<input class="row2" type="password" onkeyup="keyUp(event)" onkeydown="return onlyNumerics(event)" tabindex="2" maxlength="9" size="20" name="PIN" id="PIN" autocomplete="off">
</td>
</tr>
<tr>
<td class="m">
<button id="side2">Login</button>
<button type="reset" id="side1">Reset</button>
</td>
</tr>
</form>
</table>
</section>
PHP:
<?php
$userid = $_POST['uid'];
echo ($userid);
?>
I did this but nothing come up, it says uid is undefined. what happen?