WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
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 Resources
Web Development Content
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

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 15 times)
Viewed : 38499
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  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
Inserting data to a MySQL Database using AJAX
Categories : AJAX, HTTP, PHP, 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
Implementing a Members ONLY area
Categories : PHP, MySQL, Databases, Authentication
Checks Date-Input from HTML-Forms and converts to YYYY-MM-DD Format for MySQL Date-Fields
Categories : MySQL, Date Time, PHP, Databases
SQL / PHP based Integrated Authentication
Categories : PHP, Authentication, Databases, MySQL
Simple Mini Poll class library (SimPoll)
Categories : PHP, PHP Classes, Databases, MySQL, Complete Programs
How to thread a list of messages in database and show it in a treelike structure
Categories : PHP, MySQL, Databases
PHP and MySQL scripting for Muyltiple CheckBoxes
Categories : HTML and PHP, MySQL, Databases, PHP
Browse a MySQL database & draw a tree view & load final items into a template page.
Categories : MySQL, Complete Programs, Algorithms, PHP, Databases
Function for retrieving MySQL enum values into a PHP array.
Categories : PHP, Databases, MySQL, Arrays
Function to check connection to MySQL and redirect to an error page if an error occurs
Categories : MySQL, PHP, Debugging, Databases