Got a session question this time.
Page 1 - I am choosing a date with a "date picker" and entering the values of the start date and end date into a session - works fine
Page 2 - Pulling those values from session and using them as data to enter into a mysql DB - works fine
After the sql insert script runs (works fine) it then calls header ('Location: payroll-list-contractors.php'); and sends user back to page 1 again to choose another contractor from the list.
But, the session does not follow for some reason after the header is called.
Both scripts are in the same directory / domain / etc...
I have found a lot on this subject but nothing I have tries seems to work, including:
putting .SID after the header
session_write_close(); before the header call
Thank you for any help.
Page 1----
<?php
session_start();
include '../admin/includes/authorize.php';
include '../admin/includes/dbconnect.php';
$_SESSION['payroll_start_date'] = $_REQUEST["start_date"];
$_SESSION['payroll_end_date'] = $_REQUEST["end_date"];
$payroll_start_date = $_SESSION['payroll_start_date'];
$payroll_end_date = $_SESSION['payroll_end_date'];
?>
Page 2 ------
<?php
session_start();
//ini_set('display_errors', 1);
//error_reporting(E_ALL|E_STRICT);
include '../admin/includes/authorize.php';
include '../admin/includes/dbconnect.php';
$client_id = $_SESSION['client_id'];
$payroll_start_date = $_SESSION['payroll_start_date'];
$payroll_end_date = $_SESSION['payroll_end_date'];
$contractor_id = $_GET["contractor_id"];
$result = mysql_query("SELECT first_name, last_name FROM CONTRACTORS WHERE contractor_id = '$contractor_id'");
$row = mysql_fetch_array($result) or die(mysql_error());
$first_name = $row['first_name'];
$last_name = $row['last_name'];
if(isset($_POST['submit'])) {
$query = "INSERT INTO PAYROLL SET `client_id` = '".$_SESSION['client_id']."',`contractor_id` = '".$_GET["contractor_id"]."' ,`payroll_start_date` = '".$_GET["payroll_start_date"]."' ,`payroll_end_date` = '".$_GET["payroll_end_date"]."' ,`hours_worked` = '".$_POST['hours_worked']."', `hourly_rate` = '".$_POST['hourly_rate']."', `deductions` = '".$_POST['deductions']."',`advance` = '".$_POST['advance']."',`comments` = '".$_POST['comments']."',`date_entered` = NOW()";
mysql_query($query) or die(mysql_error());
session_write_close();
header('Location: payroll-list-contractors.php');
}
?>