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
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
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



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 : Inserting data to a MySQL Database using AJAX
Categories : AJAX, HTTP, PHP, Databases, MySQL Click here to Update Your Picture
Laxman Kemase
Date : Oct 01st 2011
Grade : 2 of 5 (graded 8 times)
Viewed : 20642
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Laxman Kemase
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
Like this code?
Show the author your appreciation.
 

Run the register.php file. The onclick of the Submit button will call the add_record function to take the form data and send it to the request page.


register.php
<script>
function add_record()
{
  var fname = document.register.fname.value;
  var lname = document.register.lname.value;
  var email = document.register.email.value;
  var password = document.register.pass.value;
 
  var str = fname+"_"+lname+"_"+email+"_"+password;
 
     if (str=="")
      {
          document.getElementById("msg").innerHTML="";
          return;
      }
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
     
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            document.getElementById("msg").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","add.php?str="+str,true);
    xmlhttp.send();
   
    document.register.fname.value = "";
    document.register.lname.value = "";
    document.register.email.value = "";
       document.register.pass.value = "";
}
</script>

<form name="register" method="post" action="">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
     <td bgcolor="#CCCCCC" height="250" align="left" width="50%">
       
         <table width="50%" border="0" cellspacing="1" cellpadding="0">
          <tr>
            <td bgcolor="#CCCCCC" align="center"><strong></strong></td>
             <td bgcolor="#CCCCCC" align="left" height="30"><strong> Register</strong></td>
          </tr>
          <tr>               
                <td bgcolor="#CCCCCC" align="center"></td>
                <td bgcolor="#CCCCCC" id="msg" align="left"></td>
          </tr>
          <tr>
            <td bgcolor="#CCCCCC" align="right">First Name: </td>
            <td bgcolor="#CCCCCC"><input name="fname" type="text" size="20" /></td>
          </tr>
           <tr>
            <td bgcolor="#CCCCCC" align="right">Last Name: </td>
            <td bgcolor="#CCCCCC"><input name="lname" type="text" size="20" /></td>
          </tr>
           <tr>
            <td bgcolor="#CCCCCC" align="right">Email: </td>
            <td bgcolor="#CCCCCC"><input name="email" type="text" size="20" /></td>
          </tr>
           <tr>
            <td bgcolor="#CCCCCC" align="right">Password: </td>
            <td bgcolor="#CCCCCC"><input name="pass" type="text" size="20" /></td>
          </tr>
          <tr>
            <td bgcolor="#CCCCCC" ></td>
            <td bgcolor="#CCCCCC"><input name="add" type="button" value="Submit" onclick="add_record()"/></td>
          </tr>
         </table>
       
    </td>
  </tr>
</table>
</form>



//add.php
<?php
   
//include("include.php");
   
    //$get_Info = new database(DB_ICA);
    //$get_Info -> db_connect();
   
       
$conn = mysql_connect("localhost","root","");
       
mysql_select_db("db_name",$conn);

   
$str = explode("_",$_REQUEST["str"]);
   
   
$sql_trip = "INSERT INTO test (fname,lname,email,password)
         VALUES(
               .
$str[0].,
               .
$str[1].,
               .
$str[2].,
               .
$str[3].
               )"
;
       
   
$res = mysql_query($sql_trip);   
   
    if(
$res)
    {
        echo
"Record successfully inserted.";
    }
 
?>



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
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
Simple pipe delimited file export program that downloads to a local machine
Categories : PHP, Filesystem, Databases, MySQL, HTTP
Identify and log search engine access (spiders, robots, etc.) to a page.
Categories : HTTP, Environment Variables, PHP, MySQL, Databases
The simple counter with use MySql and gd.
Categories : MySQL, HTTP, Graphics, PHP, 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
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
AJAX Application
Categories : PHP, AJAX, Databases, MySQL
bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager
Categories : MySQL, PHP, MySQL, Complete Programs, Databases
Paginating the mySQL data
Categories : PHP, Algorithms, Databases, MySQL, HTML and PHP
php-gtk mysql querying tool
Categories : PHP-GTK, MySQL, PHP, Databases
phpMyDataGrid 2007
Categories : AJAX, PHP Classes, MySQL, Databases, HTML and PHP
This functions makes it easy to use session-variables known from ASP. With one Cookie the array "session" will save and restore from a db-record. In this version MySQL is used but it's should very easy to change
Categories : PHP, Arrays, Cookies, MySQL, Databases
Function to do live population of HTML's <Select> tag from a Table
Categories : PHP, MySQL, HTML and PHP, Databases