i also tried teh query in phpmyadmin just replacing teh variables with values.
here is the code for the insert its similar to the update only it runs a different sql query
Code: Select all
<?PHP //error_reporting(E_ALL);
//start the session
session_start();
//check to make sure the session variable isn't registered
if(!session_is_registered('EmpID')){
//the session variable isn't registered, send them back to the login page
header( "Location: JMSystemLogin.php" );
}
else
{
$EmpID = $_SESSION['EmpID'];
include ('connect_db.php');
$JobID = $_POST['JobID'];
$UnitID = $_POST['Unit'];
$OpndBy = $_POST['OpenedBy'];
$Assign = $_POST['AssignTo'];
$OpnDate = Date ("Y-m-d H:i:s");;
$WrkArea = $_POST['WorksArea'];
$Priority = $_POST['Priority'];
$Desc = addslashes($_POST['Description']);
$Comments = addslashes($_POST['Comments']);
if ($JobID == NULL || $UnitID == NULL || $OpndBy == NULL || $Assign == NULL || $OpnDate == NULL || $WrkArea == NULL || $Priority == NULL || $Desc == NULL)
{
$error = "Please fill out all of the starred fields. Cant set fileds to a null value";
header( "Location: AddNew.php?error=$error" );
}
else
{
if ($Priority==1)
{
$TargetDate = date ('Y-m-d H:i:s', strtotime('today +1 days'));
}
else if ($Priority==2)
{
$TargetDate = date ('Y-m-d H:i:s', strtotime('today +2 days'));
}
else if ($Priority==3)
{
$TargetDate = date ('Y-m-d H:i:s', strtotime('today +3 days'));
}
else
{
$TargetDate = date ('Y-m-d H:i:s', strtotime('today +4 days'));
}
$insert = "INSERT INTO Job (JobID, Client_ClientID, Employee_EmployeeID, Units_UnitID, JobDescription, JobOpendBy, Priority, DateSubmitted, TargetDate, Comments) VALUES ('$JobID', '$WrkArea', '$EmpID', '$UnitID', '$Desc', '$OpndBy', '$Priority', '$OpnDate', '$TargetDate', '$Comments')";
$result = mysql_query($insert);
if (!$result)
{
$error = "Insert Failed. Null Values";
header( "Location: AddNew.php?error=$error" );
}
else
{
$error = "Insert Successful";
header ("location: Jobs.php?error=$error");
}
}
if (empty($JobID) || empty($UnitID) || empty($OpndBy) || empty($Assign) || empty($OpnDate) || empty($WrkArea) || empty($Priority) || empty($Desc))
{
$error = "Please fill out all of the starred fields. Cant have any empty fields";
header( "Location: AddNew.php?error=$error" );
}
else
{
if ($Priority==1)
{
$TargetDate = date ('Y-m-d H:i:s', strtotime('today +1 days'));
}
else if ($Priority==2)
{
$TargetDate = date ('Y-m-d H:i:s', strtotime('today +2 days'));
}
else if ($Priority==3)
{
$TargetDate = date ('Y-m-d H:i:s', strtotime('today +3 days'));
}
else
{
$TargetDate = date ('Y-m-d H:i:s', strtotime('today +4 days'));
}
$insert = "INSERT INTO Job (JobID, Client_ClientID, Employee_EmployeeID, Units_UnitID, JobDescription, JobOpendBy, Priority, DateSubmitted, TargetDate, Comments) VALUES ('$JobID', '$WrkArea', '$EmpID', '$UnitID', '$Desc', '$OpndBy', '$Priority', '$OpnDate', '$TargetDate', '$Comments')";
$result = mysql_query($insert);
if (!$result)
{
$error = "Insert Failed. Empty Values";
header( "Location: AddNew.php?error=$error" );
}
else
{
$error = "Insert Successful";
header ("location: Jobs.php?error=$error");
}
}
}
?>