<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
if($_POST['name'] == '' || $_POST['id'] == '')
{
$message="page refresh";
echo $message;
}
else
{
$user = "root";
$host="localhost";
$pass = "admin";
$db = "mydatabase";
$table = "customer";
$con=mysql_connect($host,$user,$pass) or die( "DB connection error:".mysql_error());
$dbcon=mysql_select_db($db,$con) or die ( "Db Selection error:".mysql_error());
$name=$_POST['name'];
$id=$_POST['id'];
$sql="insert into $table values ('$name','$id')";
$result=mysql_query($sql) or die(" insert error :".mysql_error());
}
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" name="form1">
<table width="100%" border="1">
<tr>
<td>Employee Name</td>
<td width="2%">:</td>
<td ><input type="text" name="name" id="textfield" /></td>
<td>Employee No</td>
<td width="2%">:</td>
<td><label>
<input type="text" name="id" id="textfield2" />
</label></td>
</tr>
<tr>
<td colspan="6" align="center"><input type="submit" name="name1" value="register" />
<input type="submit" name="id" value="cancel" /></td>
</tr>
</table>
</form>
</body>
</html>
Bookmarks