I have this program that inserts data into a database and would like to be able to repeat the form for further data inserts upon submission but don't know how. Below is code for the form & the testinsert.php:
<html>
<head>
<style type="text/css">
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
function getResults() {
var search_val = $("#apt").val();
$.post("prerentget.php", { search_term: search_val }, function(data) {
if (data.length > 0) {
$("#name")[0].value = data;
}
})
}
</script>
<script type="text/javascript">
window.google_analytics_uacct = "UA-256751-2";
</script>
</head>
<body onload="document.form.apt.focus()">
<form name="form" action="testinsert.php" method="post">
<!--code for the form-->
<INPUT type="submit" value="submit data" />
</p>
</form></body></html>
<?php
$apt=$_POST['apt'];
$name=$_POST['name'];
$datereceived=$_POST['datereceived'];
$time=$_POST['time'];
$symptom=$_POST['symptom'];
$action=$_POST['action'];
$compmo=$_POST['compmo'];
$compday=$_POST['compday'];
$compyear=$_POST['compyear'];
$ordno=$_POST['ordno'];
$stat = mysql_connect("localhost","root","") or die('Unable to connect to database: ' . mysql_error());
$stat = mysql_select_db("maintdb") or die('Unable to select database: ' . mysql_error());
$query = "INSERT INTO maintdata
(apt,name,datereceived,time,symptom,action,compmo,compday,compyear,ordno)
VALUES('$apt','$name','$datereceived','$time','$symptom','$action','$compmo','$compday','$compyear','$or
dno')";
$stat = mysql_query($query) or die('Query failed: ' . mysql_error());
mysql_close();
?>