...

View Full Version : Help passing variables back to their original form textareas...



modigy
06-10-2006, 10:10 PM
Hi All,

I have an addbook.php form for my clients. This information gets posted to the submitbook.php page that connects to the MySQL database and adds the records. Then sends them back to a blank addbook.php form to add another record. I would like some of the variables to be sent back to the original Input.php form so the client can add another record without 're-entering' everything all over again.

Code Snipets----------

addbook.php
*************

<?
if ($subject == "") {
echo '<input name="theme" type="text" id="theme" value="children" maxlength="20">';

} else {
What can I put here...or do I need anything here???
}
?>
***************

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."','".$shippingDelay."','".$distributor."','".$display."','".$entryDate."')";
$i++;
$result=mysql_query($submit);
}


if ($result)
{
// Data submitted. Returning to main book page.';
header('Location: addbook.php');
Should I have anything here to send the variables back??

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



?>
<p>&nbsp;</p>
</body>
</html>
*************

How can I get a variable sent back to the 'addbook.php' form and populated in it's respective field??

Please let me know...I have been looking all over for a week now and have even posted this question in other forums with no responses.

Thanks in advance,


M

chump2877
06-10-2006, 10:52 PM
I would create/start a session here and store your reused values in SESSION variables (create the SESSION variables in submitbook.php, then recall them in addbook.php)...

A link on SESSION variabels: http://us3.php.net/manual/en/ref.session.php

a tutorial: http://codewalkers.com/tutorials/32/1.html

modigy
06-12-2006, 12:55 PM
Thanks for your quick response,

I am getting the following error:

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/jandj/public_html/jandjpanel/addbook.php:11) in /home/jandj/public_html/jandjpanel/addbook.php on line 122

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/jandj/public_html/jandjpanel/addbook.php:11) in /home/jandj/public_html/jandjpanel/addbook.php on line 122

Here is what I have so far:

addbook.php
**********

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Add book</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../jandj.css" rel="stylesheet" type="text/css">
</head>

<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';
}
?>


<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif">Add book</font></div>
<form name="lookupform" method="post" action="addbook_lookup.php">
<span class="formcontent">ISBN new:</span>
<? echo '<input name="isbn" type="text" value="'.$isbn.'" id="isbn">'; ?>
<input type="submit" name="Submit2" value="Lookup">
</form>

<form name="form1" method="post" action="submitbook.php">
<p><b></b></p>
<table width="100%" border="0">

<tr>
<td><input type="submit" name="Submit" value="Submit"></td>
<td>
<? echo '<input name="isbn" type="hidden" value="'.$isbn.'">'; ?>

</td>
</tr>

<tr>
<td><span class="formcontent">J&amp;J Price:</span></td>
<td><input name="priceAct" type="text" id="priceAct" maxlength="20"></td>
</tr>
<tr>
<td><span class="formcontent">Publisher Price:</span></td>
<td><input name="pricePub" type="text" id="pricePub" maxlength="20"></td>
</tr>
<tr>
<td><span class="formcontent">Number of copies:</span></td>
<td><input name="copies" type="text" id="copies" size="4" maxlength="3"></td>
</tr>
<tr>
<td width="22%"><span class="formcontent">Title:</span> </td>
<td width="78%">
<?
echo '<input name="title" type="text" id="title" size="50" value="'.$title.'">';
?>
</td>
</tr>
<tr>
<td><span class="formcontent">Author:</span></td>
<td>
<?
echo '<input name="author" type="text" id="author" size="50" value="'.$author.'" maxlength="200">';
?>
</td>
</tr>
<tr>
<td><span class="formcontent">Publisher:</span></td>
<td>
<?
echo '<input name="publisher" type="text" id="publisher" size="50" value="'.$publisher.'" maxlength="100">';
?>
</td>
</tr>
<tr>
<td><span class="formcontent">Distributor:</span></td>
<td>
<?
echo '<input name="distributor" type="text" id="distributor" size="50" value="'.$distributor.'" maxlength="100">';
?>
</td>
</tr>
<tr>
<td><span class="formcontent">Date:</span></td>
<td>
<?
echo '
<input name="month" type="text" id="month" value="'.$month.'" size="3" maxlength="2">
/
<input name="year" type="text" id="year" value="'.$year.'" size="3" maxlength="2">';
?>
(month/year)</td>
</tr>
<tr>
<td><span class="formcontent">Commentary:</span></td>
<td><textarea name="commentary" cols="50" rows="5" id="commentary"><? echo $commentary ?></textarea></td>
</tr>
<tr>
<td><span class="formcontent">Image</span></td>
<td>
<?
if ($isbn == "") {
echo '<input name="image" type="text" id="image" value="na.gif" maxlength="50">';
} else {
echo '<input name="image" type="text" id="image" value="'.$isbn.'.jpg" maxlength="50">';
}
?>
</td>
</tr>
<tr>
<td><span class="formcontent">Published</span></td>
<td><input name="published" type="checkbox" id="published" value="checkbox"></td>
</tr>
<tr>
<td><span class="formcontent">Theme:</span></td>
<td>

<?
session_start();
if (isset ($_SESSION['theme'])) {
echo '<input name="theme" type="text" id="theme" value="'.$_SESSION['theme'].'">';
} else {
echo '<input name="theme" type="text" id="theme" value="children" maxlength="20">';
}
?> />



</td>
</tr>
<tr>
<td><span class="formcontent">Recommended:</span></td>
<td><input name="recommend" type="checkbox" id="recommend" value="1"></td>
</tr>
<tr>
<td><span class="formcontent">Reference Num:</span></td>
<td><input name="referenceNum" type="text" id="referenceNum" value="0" maxlength="20"></td>
</tr>
<tr>
<td><span class="formcontent">Tracking Num:</span></td>
<td><input name="trackingNumber" type="text" id="trackingNumber" value="000000000000" maxlength="20"></td>
</tr>
<tr>
<td><span class="formcontent">Grade Level:</span></td>
<td><input name="gradeLevel" type="text" id="gradeLevel" value="PreK-2" maxlength="20"></td>
</tr>
<tr>
<td><span class="formcontent">Shipping Delay:</span></td>
<td><input name="shippingDelay" type="text" id="shippingDelay" value="2" size="4" maxlength="4"></td>
</tr>
<tr>
<td><span class="formcontent">Display on Site: </span></td>
<td><select name="display" id="display">
<option value="MB" selected>Madrid Books</option>
<option value="JJ">J and J</option>
<option value="Both">Both</option>
<option value="None">Neither</option>
</select>
</td>
</tr>
</table>
<p>&nbsp; </p>
</form>

</body>
</html>
****************

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'];

session_start();
$_SESSION["theme"] = "$theme";


//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."','".$shippingDelay."','".$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>&nbsp;</p>
</body>
</html>
**************

I sense I've done something wrong here, I'm just not sure what. Can you give me any ideas?

Thank you,

M

chump2877
06-12-2006, 01:49 PM
you only need to call session_start() once for each file that uses SESSION variables, and it should appear at the very beginning of your file before any HTTP header output has been sent to the browser....like this:


<? session_start(); ?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

...and code continues here...

modigy
06-12-2006, 04:40 PM
Ok...slowly but surely...

I'm no longer getting the error. I have placed the session_start() at the begining of the page. However, now that the variable is set, I can't seem to change it unless I clear cookies. How can this session variable be reset if the user begins entering new data?

Ex:

User has 30 books under the theme of 'Mystery'

After they've entered these 30 they now have 15 under 'Children'

However the variable is still set to 'Mystery' and it appears the only way to clear the current variable is to clear cookies or close the browser.

I'm almost there...and you've already helped out imensely...

Thanks,

M

chump2877
06-12-2006, 08:03 PM
well you could do a couple of things:

1) you could just reassign the SESSION variable a different value every time the value changes....so, i.e., if $_SESSION['pet'] == 'dog', then you could change the value with this statement:


$_SESSION['pet'] = 'cat';

I think that should work, but if it doesn;t try #2...

2) every time the value of, i.e., $_SESSION['pet'] changes, you could unset the variable and recreate it with a new value...so again, if $_SESSION['pet'] == 'dog', then:


unset($_SESSION['pet']);
$_SESSION['pet'] = 'cat';

And when you want to kill the SESSION entirely, use session_destroy():


// Unset all of the session variables.
$_SESSION = array();

// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}

// Finally, destroy the session.
session_destroy();

http://us3.php.net/manual/en/function.session-destroy.php

modigy
06-12-2006, 09:50 PM
Well...your option #1...I think I have that already. It looks to me like it should be working.

Here is what I have, perhaps you can see my mistake:

Code:

addbook.php
*************
<? session_start(); ?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Add book</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../jandj.css" rel="stylesheet" type="text/css">
</head>

<body>
<?php
global $title,$author,$theme,$month,$year,$subject,$publisher,$commentary;

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

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


<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif">Add book</font></div>
<form name="lookupform" method="post" action="addbook_lookup.php">
<span class="formcontent">ISBN new:</span>
<? echo '<input name="isbn" type="text" value="'.$isbn.'" id="isbn">'; ?>
<input type="submit" name="Submit2" value="Lookup">
</form>

<form name="form1" method="post" action="submitbook.php">
<p><b></b></p>
<table width="100%" border="0">

<tr>
<td><input type="submit" name="Submit" value="Submit"></td>
<td>
<? echo '<input name="isbn" type="hidden" value="'.$isbn.'">'; ?>

</td>
</tr>

<tr>
<td><span class="formcontent">J&amp;J Price:</span></td>
<td><input name="priceAct" type="text" id="priceAct" maxlength="20"></td>
</tr>
<tr>
<td><span class="formcontent">Publisher Price:</span></td>
<td><input name="pricePub" type="text" id="pricePub" maxlength="20"></td>
</tr>
<tr>
<td><span class="formcontent">Number of copies:</span></td>
<td><input name="copies" type="text" id="copies" size="4" maxlength="3"></td>
</tr>
<tr>
<td width="22%"><span class="formcontent">Title:</span> </td>
<td width="78%">
<?
echo '<input name="title" type="text" id="title" size="50" value="'.$title.'">';
?>
</td>
</tr>
<tr>
<td><span class="formcontent">Author:</span></td>
<td>
<?
echo '<input name="author" type="text" id="author" size="50" value="'.$author.'" maxlength="200">';
?>
</td>
</tr>
<tr>
<td><span class="formcontent">Publisher:</span></td>
<td>
<?
echo '<input name="publisher" type="text" id="publisher" size="50" value="'.$publisher.'" maxlength="100">';
?>
</td>
</tr>
<tr>
<td><span class="formcontent">Distributor:</span></td>
<td>
<?
echo '<input name="distributor" type="text" id="distributor" size="50" value="'.$distributor.'" maxlength="100">';
?>
</td>
</tr>
<tr>
<td><span class="formcontent">Date:</span></td>
<td>
<?
echo '
<input name="month" type="text" id="month" value="'.$month.'" size="3" maxlength="2">
/
<input name="year" type="text" id="year" value="'.$year.'" size="3" maxlength="2">';
?>
(month/year)</td>
</tr>
<tr>
<td><span class="formcontent">Commentary:</span></td>
<td><textarea name="commentary" cols="50" rows="5" id="commentary"><? echo $commentary ?></textarea></td>
</tr>
<tr>
<td><span class="formcontent">Image</span></td>
<td>
<?
if ($isbn == "") {
echo '<input name="image" type="text" id="image" value="na.gif" maxlength="50">';
} else {
echo '<input name="image" type="text" id="image" value="'.$isbn.'.jpg" maxlength="50">';
}
?>
</td>
</tr>
<tr>
<td><span class="formcontent">Published</span></td>
<td><input name="published" type="checkbox" id="published" value="checkbox"></td>
</tr>
<tr>
<td><span class="formcontent">Theme:</span></td>
<td>

<?

if (!($_SESSION['theme'] == "")) {
echo '<input name="theme" type="text" id="theme" value="'.$_SESSION['theme'].'">';
} else {
echo '<input name="theme" type="text" id="theme" value="" maxlength="20">';
}
?>



</td>
</tr>
<tr>
<td><span class="formcontent">Recommended:</span></td>
<td><input name="recommend" type="checkbox" id="recommend" value="1"></td>
</tr>
<tr>
<td><span class="formcontent">Reference Num:</span></td>
<td><input name="referenceNum" type="text" id="referenceNum" value="0" maxlength="20"></td>
</tr>
<tr>
<td><span class="formcontent">Tracking Num:</span></td>
<td><input name="trackingNumber" type="text" id="trackingNumber" value="000000000000" maxlength="20"></td>
</tr>
<tr>
<td><span class="formcontent">Grade Level:</span></td>
<td><input name="gradeLevel" type="text" id="gradeLevel" value="PreK-2" maxlength="20"></td>
</tr>
<tr>
<td><span class="formcontent">Shipping Delay:</span></td>
<td><input name="shippingDelay" type="text" id="shippingDelay" value="2" size="4" maxlength="4"></td>
</tr>
<tr>
<td><span class="formcontent">Display on Site: </span></td>
<td><select name="display" id="display">
<option value="MB" selected>Madrid Books</option>
<option value="JJ">J and J</option>
<option value="Both">Both</option>
<option value="None">Neither</option>
</select>
</td>
</tr>
</table>
<p>&nbsp; </p>
</form>

</body>
</html>
*************

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'];

session_start();
$_SESSION["theme"] = "$theme";


//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."','".$shippingDelay."','".$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>&nbsp;</p>
</body>
</html>
*************

With what I have so far, the 'theme' field comes up empty everytime I come back to the form to add another entry. What am I missing??

Thanks,


M

chump2877
06-12-2006, 10:29 PM
try changing this code:


<?

if (!($_SESSION['theme'] == "")) {
echo '<input name="theme" type="text" id="theme" value="'.$_SESSION['theme'].'">';
} else {
echo '<input name="theme" type="text" id="theme" value="" maxlength="20">';
}
?>

to:


<?

if (!empty($_SESSION['theme'])) {
echo '<input name="theme" type="text" id="theme" value="'.$_SESSION['theme'].'">';
echo '<br>the session variable is NOT empty'; // just some error checking here
} else {
echo '<input name="theme" type="text" id="theme" value="" maxlength="20">';
echo '<br>the session variable is empty'; // more error checking
}
?>

if this prints 'the session variable is empty', then try printing the value of $_SESSION['theme'] to the browser...if its still empty, then in this line of code here:


$_SESSION["theme"] = "$theme";

it is likely that $theme doesn;t have a value or is empty....which means $HTTP_POST_VARS['theme'] is empty...se where I'm going with this....

Moral of the story: you can print out all of your variables to the browser to find out which variables have values and which dont, and thus isolate the problem to particular section of code...


And please use PHP tags when displaying your code in this post, it makes it easier to read: http://www.codingforums.com/showthread.php?t=68462

modigy
06-13-2006, 04:14 PM
FINALLY!!

I think I've got it now!!

This is what I've ended up with:

addbook.php

<?

if (isset ($_SESSION['theme'])) {
echo '<input name="theme" type="text" id="theme" value="'.$_SESSION['theme'].'">';
echo '<br>the session variable is NOT empty';
} else {
echo '<input name="theme" type="text" id="theme" value="" maxlength="20">';
echo '<br>the session variable is empty';
}
?>

AND

submitbook.php

<?php

session_start();

$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."','".$shippingDelay."','".$distributor."','".$display."','".$entryDate."')";
$i++;
$result=mysql_query($submit);
}


if ($result)
{
// Data submitted. Returning to main book page.';

$_SESSION["theme"] = "$theme";
header('Location: addbook.php');


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



?>

Thank you for all of your help!!


M



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum