Jump to content

Archived

This topic is now archived and is closed to further replies.

modigy

Maintaining FORM data for consecutive entries

Recommended Posts

Hi...here's the problem:

I have a .php form 'addbook.php' that sends the textfield entries to another .php file 'submitbook.php' which opens a mysql connection and populates the database. Once the connection is made the data is placed in a table and 'submitbook.php' returns the client to the 'addbook.php' form if they would like to add another book.

My client sometimes enters 100s of entries under the same field names (mystery, drama, etc.). However, it returns them to 'addbook.php' and the form is blank.

How can return a variable back to the form so my client can maintain certain field entries for 'data-entry'?

Example: My client enters 100 books under the Subject: of 'Mystery'. For each book they have to re-type the Subject: 'Mystery'.

Here is a portion of my code:

<--addbook.php-->

**variables (top of page)**
<body>
<?php
global $title,$author,$subject,$month,$year,$subject,$publisher,$commentary;

$title = $author = $subject = $month = $year = $subject = $publisher = $commentary ="";

$isbn=$HTTP_POST_VARS['isbn'];
if ($isbn != "") {
include 'xmlparser_rc2.php';
}
?>

**/variables (top of page)**

**form excerpt**

<td><span class="formcontent">Publisher:</span></td>
<td>
<?
echo '<input name="publisher" type="text" id="publisher" size="50" value="'.$publisher.'" maxlength="100">';
?>
</td>

**/form excerpt**

<--submitbook.php-->

<?php
$title=$HTTP_POST_VARS['title'];
$isbn=$HTTP_POST_VARS['isbn'];
$author=$HTTP_POST_VARS['author'];
$publisher=$HTTP_POST_VARS['publisher'];
$commentary=$HTTP_POST_VARS['commentary'];
$image=$HTTP_POST_VARS['image'];
$theme=$HTTP_POST_VARS['theme'];
$recommend=$HTTP_POST_VARS['recommend'];
$referenceNum=$HTTP_POST_VARS['referenceNum'];
$pricePub=$HTTP_POST_VARS['pricePub'];
$priceAct=$HTTP_POST_VARS['priceAct'];
$day=$HTTP_POST_VARS['day'];
$month=$HTTP_POST_VARS['month'];
$year=$HTTP_POST_VARS['year'];
$trackingNumber=$HTTP_POST_VARS['trackingNumber'];
$gradeLevel=$HTTP_POST_VARS['gradeLevel'];
$copies=$HTTP_POST_VARS['copies'];
$shippingDelay=$HTTP_POST_VARS['shippingDelay'];
$distributor=$HTTP_POST_VARS['distributor'];
$display=$HTTP_POST_VARS['display'];
$date=$year."-".$month."-".$day;

$tempdate = getdate( );
$entryDate = $tempdate['year'].'-'.$tempdate['mon'].'-'.$tempdate['mday'];

//Connect to database
$database=mysql_pconnect('localhost','jandj_root');
if (!$database)
{
header('Location: errorbook?type=1.php');
exit;
}

mysql_select_db('books');
$query="select * from jandj_jandj.books";
$result=mysql_query($query);
$column=mysql_fetch_array($result);
$i = 0;
while ($i<$copies) {
$submit="INSERT INTO jandj_jandj.books VALUES

('','".$title."','".$isbn."','".$author."','".$date."','".$commentary."','','".$image."','','".$theme."','".$recommend."',

'".$referenceNum."','".$pricePub."','".$priceAct."','".$publisher."','".$trackingNumber."','".$gradeLevel."','".$shippingD

elay."','".$distributor."','".$display."','".$entryDate."')";
$i++;
$result=mysql_query($submit);
}


if ($result)
{
// Data submitted. Returning to main book page.';
header('Location: addbook.php');


} else {
// header('Location: errorbook.php?type=2');
echo 'Error submitting book info!<br>
$submit = '.$submit;
}



?>
<p> </p>
</body>
</html>

*********************

Please let me know what I can do here...I've been looking all over [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /]

Thanks in advance...M

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.