WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : AJAX Application
Categories : PHP, AJAX, Databases, MySQL Click here to Update Your Picture
Sujith Kumar
Date : May 24th 2006
Grade : 3 of 5 (graded 10 times)
Viewed : 15433
File : 4408.zip
Images : No Images for this code example.
Search : More code by Sujith Kumar
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

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>&nbsp;</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">&nbsp;</td>
    <td width="97" bgcolor="#D4D0C8">&nbsp;</td>
    <td colspan="3" bgcolor="#D4D0C8">&nbsp;</td>
  </tr>
  <tr>
    <td bgcolor="#D4D0C8">&nbsp;</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">&nbsp;</td>
  </tr>
  <tr>
    <td bgcolor="#D4D0C8">&nbsp;</td>
    <td bgcolor="#D4D0C8">&nbsp;</td>
    <td colspan="2" bgcolor="#D4D0C8">&nbsp;</td>
    <td bgcolor="#D4D0C8">&nbsp;</td>
  </tr>
  <tr>
    <td bgcolor="#D4D0C8">&nbsp;</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">&nbsp;</td>
  </tr>
  <tr>
    <td bgcolor="#D4D0C8">&nbsp;</td>
    <td bgcolor="#D4D0C8">&nbsp;</td>
    <td colspan="3" bgcolor="#D4D0C8">&nbsp;</td>
  </tr>
  <tr>
    <td bgcolor="#D4D0C8">&nbsp;</td>
    <td bgcolor="#D4D0C8">&nbsp;</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">&nbsp;</td>
  </tr>
  <tr>
    <td bgcolor="#D4D0C8">&nbsp;</td>
    <td bgcolor="#D4D0C8">&nbsp;</td>
    <td colspan="3" bgcolor="#D4D0C8">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="5" bgcolor="#D4D0C8"><hr></td>
  </tr>
</table>
<p>&nbsp;</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">&nbsp;</td>
    <td width="84" bgcolor="#D4D0C8">Name</td>
    <td width="124" bgcolor="#D4D0C8">'
.$Values['name'].'</td>
  </tr>

<tr>
    <td bgcolor="#D4D0C8">&nbsp;</td>
    <td bgcolor="#D4D0C8">Street</td>
    <td bgcolor="#D4D0C8">'
.$Values['street'].'</td>
  </tr>
  <tr>
    <td bgcolor="#D4D0C8">&nbsp;</td>
    <td bgcolor="#D4D0C8">City</td>
    <td bgcolor="#D4D0C8">'
.$Values['city'].'</td>
  </tr>
  <tr>
    <td bgcolor="#D4D0C8">&nbsp;</td>
    <td bgcolor="#D4D0C8">State</td>
    <td bgcolor="#D4D0C8">'
.$Values['state'].'</td>
  </tr>
  <tr>
    <td bgcolor="#D4D0C8">&nbsp;</td>
    <td bgcolor="#D4D0C8">Country</td>
    <td bgcolor="#D4D0C8">'
.$Values['country'].'</td>
  </tr>
  <tr>
    <td bgcolor="#D4D0C8">&nbsp;</td>
    <td bgcolor="#D4D0C8">Zip</td>
    <td bgcolor="#D4D0C8">'
.$Values['zip'].'</td>
  </tr>
  <tr>
    <td bgcolor="#D4D0C8">&nbsp;</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
This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server.
Categories : Databases, MySQL, Complete Programs, PHP, Databases
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
Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs.
Categories : Databases, PHP, MySQL, Complete Programs
phpAds, a complete banner and ad management system with detailled tracking and stats.
Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases
Point and Click Interface ala MS Access for creating SQL statements.
Categories : MySQL, Complete Programs, General SQL, PHP, Databases
Message of the Day - Random Message (Needs MySQL!)
Categories : Databases, HTML and PHP, PHP, MySQL
email new items in db
Categories : PHP, Email, Databases, MySQL, Beginner Guides
Alternating background color for HTML table rows
Categories : PHP, Databases, MySQL, HTML and PHP
color codes for positive and negative numbers
Categories : PHP, MySQL, Databases, HTML
A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL
Linked comboboxes with php-mysql & javascript
Categories : PHP, Java Script, Databases, MySQL
mysql_escape_string
Categories : PHP, MySQL, Databases, Strings