PHP Login Source:
The following is the chklogin.php page code:
<?php
Session_Start ();
$connect =mysql_connect ("127.0.0.1", "root", "123");
if (! $connect)
{
Die (' Could not connect: '. Mysql_error ());
}
mysql_select_db (design, $connect);
$query = "SELECT * from ta_user where user_name = '". $name. "'";
$result =mysql_query ($query) or Die ("Unable to connect to MySQL");
$rows =mysql_fetch_array ($result);
if ($rows [user_password]== $pwd)
{
Header ("Location:login_suss.php?name=". $name. "");
}
Else
{
echo "<table width= ' 235 ' height= ' border= ' 0 ' align= ' center ' >";
echo "<tr><td height=" > Username or password is wrong! </td></tr> ";
echo "<tr><td height= ' > Please click <a href= ' Javascript:history.go (-1); ' > Here </a> re-enter! ";
echo "</td></tr>";
echo "</table>";
}
?>
Example of an AJAX code for landing verification:
<script language= "JavaScript" >
function Getxmlhttprequest ()
{
var xrequest=null;
if (window. XMLHttpRequest)
{
Xrequest=new XMLHttpRequest ();
}
else if (typeof activexobject!= "undefined")
{
Xrequest=new ActiveXObject ("Microsoft.XMLHTTP");
}
return xrequest;
}
function Ajax (URL)
{
Ajaxobj = Getxmlhttprequest ();
Ajaxobj.onreadystatechange = ProcessRequest;
Ajaxobj.open ("Post", url,true);
Ajaxobj.setrequestheader (' Content-type ', ' application/x-www-form-urlencoded ');
Ajaxobj.send ("name" +name);
}
function ProcessRequest ()
{
if (ajaxobj.readystate = 4)
{
if (Ajaxobj.status = 200)
{
if (Ajaxobj.responsetext!= "")
{
document.getElementById ("Show"). Innerhtml= "";
alert (Ajaxobj.responsetext);
document.getElementById ("Show"). Innerhtml=ajaxobj.responsetext;
}
}
Else
{
Alert ("The page you are requesting has an exception.) ")
}
}
Else
{
document.getElementById ("Show"). Innerhtml= "Loading ...";
}
}
</script>
In practical application, use; call on the line.