Forum Moderators: open
The thing is, im trying to have it so that once this function gets triggered on index.html:
<script type="text/javascript">
function loginsubmit(){
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if(username == ""){
alert("Please enter your username!");
return false;}
if(password == ""){
alert("Please enter your password!");
return false;}
else{
postRequest();}
}
</script>
and everything is correct it triggers this ajax function:
<script type="text/javascript">
function postRequest(){
var xmlHttp;
if(window.XMLHttpRequest){ // For Mozilla, Safari, ...
var xmlHttp = new XMLHttpRequest();
}
else if(window.ActiveXObject){ // For Internet Explorer
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp.open('POST',"login.php", true);
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttp.onreadystatechange = function(){
if (xmlHttp.readyState == 4){
updatepage(xmlHttp.responseText);
}
}
xmlHttp.send(null);
}
function updatepage(){
if($gears =="yes"){
alert("Welcome User");
}else{
alert("Invalid Login! Please try again!");
}
}
</script>
which gets the contents from this php file:
<?php
$username = $_GET["username"];
$password = $_GET["password"];
if($username == "admin" && $password == "admin"){
$gears = "yes";}
else{
$gears = "no";}
?>
so it can tell ajax or html which pop up (alert) to choose all without refreshing
THANKS HEAPS!
Ricky
and your php file tofunction updatepage(re){
if(re =="yes"){
alert("Welcome User");
}
else{
alert("Invalid Login! Please try again!");
}
}
Be patient, this isn't IM.<?php
$username = $_GET["username"];
$password = $_GET["password"];
if($username == "admin" && $password == "admin"){
echo "yes";
}
?>