repeat insert form

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 Code:

<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 Code:


<?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();
?>


View full post on Webmaster-Talk.com

, ,

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes


RSS Site FeedRSS Site Feed

© 1992-2011 DC2NET™, Inc. All Rights Reserved