[query]
The problem which i face is because of the add button .Suggest me the ways to rectify it
[/query]
this is the form part of it
CODE
<html>
<body bgcolor=floralwhite leftmargin="0" topmargin="0" marginwidth="00" marginheight="0" class=NormalFont>
<form method="post" action= "adduserprocess.php" >
<LABEL>First Name</LABEL>
<input type="text" name="txtFname" maxlength="50" class="MandatoryTextBox">
<LABEL>Last Name</LABEL>
<input type="text" name="txtLname" maxlength="50" class="MandatoryTextBox">
<input type="submit" class="NormalButton" value="Add" id=button6 name=button6 onclick="doSubmit()">
<input type=Reset class=NormalButton value="Cancel" id=button6 name=button6 onclick=java script:location.href="./userlist.php">
</body>
<script language="javascript">
function doSubmit(frm)
{
if (frm.txtFname.value == "")
{
alert("Enter First Name");
frm.txtFname.focus();
}
else if(frm.txtLname.value == "")
{
alert("Enter Last Name");
frm.txtFname.focus();
}
else
{
frm.action = "./adduserprocess.php";
frm.submit();
}
}
</script>
</html>
php part
CODE
<?php
$host="localhost"; // Host name
$username=""; // Mysql username
$userpassword=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="adduser"; // Table name
if (!isset($_POST['button6'])) {
} else {
$fname = $_POST['txtFname'];
$lname = $_POST['txtLname'];
mysql_query("INSERT INTO '$tbl_name' VALUES ('null','$fname','$lname')");
echo "Success! The $fname $lname has been added!";
}
?>
<script language="javascript">
alert("<?php echo "$fname $lname"?> Successfully Added");
location.href ("./userlist.php");
</script>