I am trying to pass a variable as a cookie from one page to another, but can't seem to get it working.
The first page has a form with a submit button. The forms action goes to a second page called updated.php. In the updated.php page I have the following code (with the cookie right at the top before anything else):
<?php
setcookie("get_orderID", $get_orderID, time()+5);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
etc...
Later in this page I have the code to send the original form data to an sql database and then retireve an auto increment value back from the database as follows:
<?php
if($edit_orderID == 0)
{
$submit_order_sql = "insert into my_orders (date, name, clientID)
values ( \"$date\", \"$name\", \"$clientID\" )";
$submit_order_rs = mysql_query( $submit_order_sql, $conn );
$get_order_sql="select orderID from my_orders where job_no = $job_no";
$get_order_rs = mysql_query( $get_order_sql,$conn );
$get_order_row = mysql_fetch_array( $get_order_rs );
$get_orderID = $get_order_row["orderID"];
?>
Finally I need to send the variable I have found back to the form page (using a cookie). But it seems that as the variable is being created at the bottom of the page, the cookie at the top is not seeing the variable.
Can anyone help please??
Thanks.