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." ;
}
?>
AJAX Application Categories : PHP , AJAX , Databases , MySQL bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager Categories : MySQL , PHP , MySQL , Complete Programs , 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 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 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 Identify and log search engine access (spiders, robots, etc.) to a page. Categories : HTTP , Environment Variables , PHP , MySQL , Databases Simple pipe delimited file export program that downloads to a local machine Categories : PHP , Filesystem , Databases , MySQL , HTTP 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 Solution to those 'tell-a-friend' type email issues Categories : PHP , Email , Databases , MySQL PHP Object Example of the Perl DBI with MySQL Categories : PHP , PHP Classes , MySQL , Databases , Perl Logs hits to any page which includes it. Automatically utilises page access information left behind by PHP/FI2.0. Categories : Databases , PHP , mSQL , Databases PostGreSQL and MySQL 2 in 1 db Manager Categories : PHP , PHP Classes , Databases , PostgreSQL , MySQL Loading Images to/from MySQL Categories : Databases , MySQL , PHP , Graphics