Hello friends,
I have a very minor error, but i am not able to figure out which one is that. I have a simple form page and it goes to the another page and insert the values in database. But the thing is it inserts multiple rows in the database. here is the code
<script type="text/javascript">
function validate1(form)
{
if (form.last.value == "")
{
alert("You must enter Last Name.");
form.last.focus();
return (false);
}
if (form.first.value == "")
{
alert("You must enter First Name.");
form.first.focus();
return (false);
}
if (form.comments.value == "")
{
alert("You must enter Comments/Feedback.");
form.comments.focus();
return (false);
}
return (true);
}
</script>
<form method="post" action="submit1.php"enctype="multipart/form-data" onsubmit="return validate1(this)" name="K12">
<table >
<tr>
<td align="left" valign="top">Last Name:</td>
<td> <input type="text" size="20" name="last"></td>
</tr>
<tr>
<td align="left" valign="top">First Name:</td>
<td> <input type="text" size="20" name="first"></td>
</tr>
<tr>
<td width="110" align="left" valign="top">Comments/Feedback</td>
<td><textarea cols="60" rows="7" name="comments"></textarea></td>
</tr>
<tr>
<td width="110" align="left" valign="top"></td>
<td><br><input type="Submit" value="Submit" name="Submit">
</td>
</tr>
</table>
</form>
<?php
$first=$_POST['first'];
$last=$_POST['last'];
$comments=$_POST['comments'];
$date = date("Y-m-d");
$sql1 = "INSERT INTO feed (first_name,last_name,date,comments)VALUES('$first','$last','$date','$comments')";
$rs = mysql_query($sql1);
echo "Your feedback is submitted.";
?>