|
|
|
Simple Ajax Application
ajax_login_db.txt
|
-- Database: `ajax_login`
CREATE TABLE `admin_table` (
`admin_name` varchar(20) NOT NULL default '',
`admin_pwd` varchar(20) NOT NULL default '',
`name` varchar(20) NOT NULL default '',
`street` varchar(30) NOT NULL default '',
`city` varchar(30) NOT NULL default '',
`state` varchar(30) NOT NULL default '',
`country` varchar(30) NOT NULL default '',
`zip` int(10) NOT NULL default '0',
`email` varchar(40) NOT NULL default '',
`home` varchar(255) NOT NULL default '',
`admin_id` varchar(4) NOT NULL default '0',
PRIMARY KEY (`admin_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1; | |
CheckUser.php
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Get Customer Data</title>
<?php
error_reporting(0);
$sID = $_REQUEST["id"];
$link = mysql_connect("localhost", "root", "");
mysql_select_db("ajax_login", $link);
$result = mysql_query("Select `admin_name` from admin_table where `admin_name`='$sID'" , $link);
$num_rows = mysql_num_rows($result);
if($num_rows>0) {
$sInfo = "Please enter ur Password ";
} else {
$sInfo = "Username $sID doesn't exist.";
}
mysql_close($link);
?>
</head>
<body>
<div id="divInfoToReturn" align="center">
<?php echo $sInfo; ?>
</div>
</body>
</html> | |
display.htm
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Customer Account Information</title>
<script type="text/javascript">
var url = "CheckUser.php?id="; // The server-side script
var url_1 = "GetUserData.php?pid="; // The server-side script
function handleHttpResponse() {
if (http.readyState == 4) {
if(http.status==200) {
var results=http.responseText;
document.getElementById('divCustomerInfo').innerHTML = results;
}
}
}
function requestCustomerInfo() {
var sId = document.getElementById("txtCustomerId").value;
http.open("GET", url + escape(sId), true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
function requestpwdinfo() {
var pId = document.getElementById("pwd").value;
http.open("GET", url_1 + escape(pId), true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
function resetbut(){
document.getElementById("txtCustomerId").value='';
document.getElementById("pwd").value='';
}
function getHTTPObject() {
var xmlhttp;
if(window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}
else if (window.ActiveXObject){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
if (!xmlhttp){
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
}
return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object
</script>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
.style3 {
color: #333333;
font-weight: bold;
font-style: italic;
}
body {
background-color: #FFFFFF;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<table width="16%" height="62" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#D4D0C8">
<tr>
<td width="147" height="60" bgcolor="#D4D0C8"><div align="justify" id="divCustomerInfo" > </div>
<div align="center"></div></td>
</tr>
</table>
<p> </p>
<table width="343" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="5" bgcolor="#D4D0C8"><hr></td>
</tr>
<tr>
<td width="37" bgcolor="#D4D0C8"> </td>
<td width="97" bgcolor="#D4D0C8"> </td>
<td colspan="3" bgcolor="#D4D0C8"> </td>
</tr>
<tr>
<td bgcolor="#D4D0C8"> </td>
<td bgcolor="#D4D0C8"><span class="style3">Username</span></td>
<td colspan="2" bgcolor="#D4D0C8"><div align="center"><span class="style1">
<input name="text" type="text" id="txtCustomerId" value="" />
</span></div></td>
<td width="65" bgcolor="#D4D0C8"> </td>
</tr>
<tr>
<td bgcolor="#D4D0C8"> </td>
<td bgcolor="#D4D0C8"> </td>
<td colspan="2" bgcolor="#D4D0C8"> </td>
<td bgcolor="#D4D0C8"> </td>
</tr>
<tr>
<td bgcolor="#D4D0C8"> </td>
<td bgcolor="#D4D0C8"><strong><em>Password</em></strong></td>
<td colspan="2" bgcolor="#D4D0C8"><div align="center"><span class="style1">
<input type="password" name="textfield" id="pwd" onFocus="requestCustomerInfo()">
</span></div></td>
<td bgcolor="#D4D0C8"> </td>
</tr>
<tr>
<td bgcolor="#D4D0C8"> </td>
<td bgcolor="#D4D0C8"> </td>
<td colspan="3" bgcolor="#D4D0C8"> </td>
</tr>
<tr>
<td bgcolor="#D4D0C8"> </td>
<td bgcolor="#D4D0C8"> </td>
<td width="56" bgcolor="#D4D0C8"><input type="submit" name="Submit" onClick="requestpwdinfo()" value="Submit" ></td>
<td width="88" bgcolor="#D4D0C8"><input type="submit" name="Submit2" value="Reset" onClick="resetbut()"></td>
<td bgcolor="#D4D0C8"> </td>
</tr>
<tr>
<td bgcolor="#D4D0C8"> </td>
<td bgcolor="#D4D0C8"> </td>
<td colspan="3" bgcolor="#D4D0C8"> </td>
</tr>
<tr>
<td colspan="5" bgcolor="#D4D0C8"><hr></td>
</tr>
</table>
<p> </p>
</body>
</html> | |
GetUserData.php
| <?php
error_reporting(0);
$pID = $_REQUEST["pid"];
$link = mysql_connect("localhost", "root", "");
mysql_select_db("ajax_login", $link);
$result_1 = mysql_query("Select `admin_pwd` from admin_table where `admin_name`='$pID'" , $link);
$num_rows_1 = mysql_num_rows($result_1);
if($num_rows_1>0) {
$val_result = mysql_query("Select * from admin_table where `admin_name`='$pID'" , $link);
$Values = mysql_fetch_assoc($val_result);
$sInfo_1 = '
<table width="177" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3" bgcolor="#D4D0C8"><hr /></td>
</tr>
<tr>
<td width="24" bgcolor="#D4D0C8"> </td>
<td width="84" bgcolor="#D4D0C8">Name</td>
<td width="124" bgcolor="#D4D0C8">'.$Values['name'].'</td>
</tr>
<tr>
<td bgcolor="#D4D0C8"> </td>
<td bgcolor="#D4D0C8">Street</td>
<td bgcolor="#D4D0C8">'.$Values['street'].'</td>
</tr>
<tr>
<td bgcolor="#D4D0C8"> </td>
<td bgcolor="#D4D0C8">City</td>
<td bgcolor="#D4D0C8">'.$Values['city'].'</td>
</tr>
<tr>
<td bgcolor="#D4D0C8"> </td>
<td bgcolor="#D4D0C8">State</td>
<td bgcolor="#D4D0C8">'.$Values['state'].'</td>
</tr>
<tr>
<td bgcolor="#D4D0C8"> </td>
<td bgcolor="#D4D0C8">Country</td>
<td bgcolor="#D4D0C8">'.$Values['country'].'</td>
</tr>
<tr>
<td bgcolor="#D4D0C8"> </td>
<td bgcolor="#D4D0C8">Zip</td>
<td bgcolor="#D4D0C8">'.$Values['zip'].'</td>
</tr>
<tr>
<td bgcolor="#D4D0C8"> </td>
<td bgcolor="#D4D0C8">Email</td>
<td bgcolor="#D4D0C8">'.$Values['email'].'</td>
</tr>
<tr>
<td colspan="3" bgcolor="#D4D0C8"><hr /></td>
</tr>
</table>';
} else {
$sInfo_1 = "Password incorrect.";
}
mysql_close($link);
?>
</head>
<body>
<div id="divInfoToReturn" align="center">
<?php echo $sInfo_1; ?>
</div>
</body>
</html> | | |
| Ajax PHP Tree (Left and Right) with MySQL Categories : PHP, Databases, MySQL, AJAX, PHP Classes | | | Data Retrieve from Mysql using AJAX with PHP Categories : PHP, AJAX, Date Time, Databases, MySQL | | | bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager Categories : MySQL, PHP, MySQL, Complete Programs, Databases | |
| | AJAX Data Grid System using php and mysql. A complete login system with the ability to display data in a grid using ajax. Add , update and delete the records without reloading the page. Categories : PHP, AJAX, Databases, MySQL, Java Script | | | phpFormGenerator for Dynamic Form Generation from MySQL Categories : PHP, PHP Classes, MySQL, Databases, HTML and PHP | | | Zip code range and distance calculation class v1.0.0 Categories : PHP, Databases, MySQL, Zip Code | | | How to load a query result into a PHP Array Categories : PHP, Databases, Arrays, MySQL | | | Simple conversion functions to change MySQL dates to arrays, arrays to MySQL dates.
Categories : PHP, Arrays, Date Time, Databases, MySQL | | | Functions for loading images into a MySQL database and displaying them. Categories : Graphics, HTML and PHP, MySQL, PHP, Databases | | | for each record, do this to the first record, and do that to any subsequent record Categories : PHP, Databases, MySQL, Beginner Guides | | | PHP4 AND MySQL Authentication Categories : PHP, MySQL, Authentication, Databases | | | Displaying records of database in more than one page (paging) Categories : Databases, MySQL, PHP | | | A Complete table(ADD,EDIT,VIEW,DELETE) management System PHP,MYSQL, JAVASCRIPT Categories : PHP, MySQL, Java Script, Databases | | | This is Yet Another Sql Abstraction Library. Include it in your script and you can use the most important SQL functions without worrying about the SQL backend. Categories : Databases, PHP, ODBC, MySQL, PostgreSQL | |
|
|