Here is my code thus far:
I deleted the javascript validating somewhere along the way in a fit of WTF and now its gone.
I have been trying to figure out at the very bottom, how to include the "add_workorder_form.php" when I need it and when I don't. I want it to display initially, then if there is an error message. Once $errmsg = '' I want the table to display, and the form to go away. I got it so the table will display, but when ever I try to get the form to go away it won't show up to be filled in.
<?PHP include 'header.php'; ?>
<script type="text/javascript"> function ShowHide(id, visibility) { obj = document.getElementsByTagName("div"); obj[id].style.visibility = visibility; } </script>
<script type="text/javascript" src="calendarDateInput.js"></script>
<style type="text/css">#sub1Div { visibility:hidden; } #sub2Div { visibility:hidden; } #sub3Div { visibility:hidden; } </style>
<?php
$link = mysql_connect("localhost", "root", "apgar") or die("Could not connect");
$sql = 'SELECT * from Users';
$rs = mysql_query($sql);
$requested_by = $_POST['requested_by'];
$requested_date = $_POST['requested_date'];
$required_date = $_POST['required_date'];
$specific_date = $_POST['specific_date'];
$notify_client = $_POST['notify_client'];
$client_contact_name = $_POST['client_contact_name'];
$client_contact_telephone = $_POST['client_contact_telephone'];
$work_location = $_POST['work_location'];
$location_name = $_POST['location_name'];
$location_street = $_POST['location_street'];
$location_city = $_POST['location_city'];
$invoice_number = $_POST['invoice_number'];
$po_number = $_POST['po_number'];
$purchase_status = $_POST['purchase_status'];
$demo_pickup_date = $_POST['demo_pickup_date'];
$product_description = $_POST['product_description'];
$comments = $_POST['comments'];
if(isset($_POST['create_workorder']))
{
echo "<body onload=Javascript:";
if ($required_date == 'Specific date') { echo "ShowHide('sub1Div','visible');"; };
if ($notify_client == 'Yes') { echo "ShowHide('sub2Div','visible');"; };
if ($purchase_status == 'Demo') { echo "ShowHide('sub3Div','visible')"; };
echo " > ";
if(trim($requested_date) == '') { $errmsg = 'Please enter a valid date in the requested date field.'; }
else if(trim($required_date) == '') { $errmsg = 'Please enter a valid date in the required date field'; }
else if(trim($notify_client) == '') { $errmsg = 'Please indicate if the client needs to be contacted prior to arrival'; }
else if(trim($location_name) == '') { $errmsg = 'Please select a location, this is where the work is to be done.'; }
else if(trim($purchase_status) == '') { $errmsg = 'Please select "Sold" or "Demo, next to the purchase status. If the product is a demo please indicate a demo pickup date.'; }
else if(trim($product_description) == '') { $errmsg = 'Please give a description of the products involved.'; }
else if(trim($comments) == '') { $errmsg = 'Please use the comments field to describe the work that you are requesting to be done.'; }
if($errmsg == '')
{
echo
"
<table width='100%'>
<tr bgcolor='#FFFFFF'><td colspan='2'><font face='arial' size='+1' color='#FF0000'>Please review the information you submitted.</b></font></td></tr>
<tr bgcolor='#CCCCCC'><td width='225'><font face='arial'><b>Requested By:</b></font></td><td>$requested_by</td></tr>
<tr bgcolor='#FFFFFF'><td width='225'><font face='arial'><b>Request Made:</b></font></td><td>$requested_date</td></tr>
<tr bgcolor='#CCCCCC'><td width='225'><font face='arial'><b>Date Required:</b></font></td><td>$required_date</td></tr>
<tr bgcolor='#FFFFFF'><td width='225'><font face='arial'><b>Specific Date:</b></font></td><td>$specific_date</td></tr>
<tr bgcolor='#CCCCCC'><td width='225'><font face='arial'><b>Notifiy Client:</b></font></td><td>$notify_client</td></tr>
<tr bgcolor='#FFFFFF'><td width='225'><font face='arial'><b>Contact Name:</b></font></td><td>$client_contact_name</td></tr>
<tr bgcolor='#CCCCCC'><td width='225'><font face='arial'><b>Contact Telephone:</b></font></td><td>$client_contact_telephone</td></tr>
<tr bgcolor='#FFFFFF'><td width='225'><font face='arial'><b>Work To Be Done:</b></font></td><td>$work_location</td></tr>
<tr bgcolor='#CCCCCC'><td width='225'><font face='arial'><b>Customer Name:</b></font></td><td>$location_name</td></tr>
<tr bgcolor='#FFFFFF'><td width='225'><font face='arial'><b>Customer Street:</b></font></td><td>$location_street</td></tr>
<tr bgcolor='#CCCCCC'><td width='225'><font face='arial'><b>Customer City:</b></font></td><td>$location_city</td></tr>
<tr bgcolor='#FFFFFF'><td width='225'><font face='arial'><b>Invoice Number:</b></font></td><td>$invoice_number</td></tr>
<tr bgcolor='#CCCCCC'><td width='225'><font face='arial'><b>Purchase Order Number:</b></font></td><td>$po_number</td></tr>
<tr bgcolor='#FFFFFF'><td width='225'><font face='arial'><b>Purchase Status of Product:</b></font></td><td>$purchase_status</td></tr>
<tr bgcolor='#CCCCCC'><td width='225'><font face='arial'><b>Demo Pickup Date:</b></font></td><td>$demo_pickup_date</td></tr>
<tr bgcolor='#FFFFFF'><td width='225'><font face='arial'><b>Description of Product:</b></font></td><td>$product_description</td></tr>
<tr bgcolor='#CCCCCC'><td width='225'><font face='arial'><b>Additional Comments:</b></font></td><td>$comments</td></tr>
</table>
";
}
}
include 'add_workorder_form.php';
include 'footer.php';
?>