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
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
Mobile Dev World

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 : 2 of 5 (graded 14 times)
Viewed : 26360
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 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
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
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
Password reminder
Categories : PHP, PHP Classes, Databases, MySQL, Mail
Identify and log search engine access (spiders, robots, etc.) to a page.
Categories : HTTP, Environment Variables, PHP, MySQL, Databases
A simple script to count and report hits and the last modification time of an HTML page. Requires MySQL support (other DBs should work too, except possibly mSQL).
Categories : HTTP, MySQL, PHP, Databases
The Ajax Tree view class fetches data from a db for the requested parent category id. The data is then stored in an array and converted into JSON (Javascript Object Notation) format. This format is then used by JavaScript for populating tree view.
Categories : PHP, PHP Classes, Java Script, AJAX, Databases
create a grid out of <INPUT TYPE=TEXT> then saving to a database. Uses a 'multi-dimension array', but not really as the array is just one big array with the index of "[$i][$j]". Have a look at the code and you'll see what I mean.
Categories : PHP, MySQL, Arrays, Databases
php-gtk mysql querying tool
Categories : PHP-GTK, MySQL, PHP, Databases
Simple function to return the number of days in a time span between 2 given dates.
Categories : PHP, Date Time, MySQL, Databases
Specify your connection settings and create a link to a MySQL database.
Categories : PHP, PHP Classes, Databases, MySQL, Beginner Guides
dynamic table columns
Categories : PHP, HTML and PHP, Arrays, Databases, MySQL
mediaCat-GTK v2.0.0 - an mp3/cd/dvd cataloging utility written in php-gtk which interfaces with mysql and ms access (or db supported by PHP's Unified ODBC Functions)
Categories : PHP, MySQL, MS Access, Utilities, Databases