Normally this form would be populated by the db but I would also like to use it to
a new project as well; however, I cannot figure out how to determine if the user has hit the reset button.
PHP Code:
<?php
// start session
session_start();
// set up some global variables
@include 'menu.php';
@include 'menu_project.php';
echo '<link rel="stylesheet" type="text/css" href="style/form_style.css" />';
if(isset($_POST['project'])){
$field_list=array( 'work_flow', 'network_number', 'documentum', 'pdit',
'xfer_service', 'service_request', 'wt_accept', 'wt_ship',
'aoa', 'inco_term', 'inco_place', 'rdd',
'transit_time', 'ship_date', 'st_cd', 'float',
'st_courier', 'st_email', 'st_ftp', 'review_period',
'submit_office', 'document_level', 'margin_level', 'contigency',
'financials', 'owner', 'customer', 'consultant');
$field_list_2=array('project','project_desc');
foreach ($_POST as &$field){
$field=sanitizeMySQL($field);
}
}
//Update Project details
if(!empty($_POST['project_id'])){
update("tbl_project_details",$field_list,$_SESSION['project_id']);
update("tbl_project",$field_list_2,$_SESSION['project_id']);
echo '<head>'.
'<META HTTP-EQUIV="REFRESH" CONTENT="5;URL=display_project_details.php?project_id='.$_SESSION['project_id'].'">'.
'Project details updated.</head>';
die;
}
//New staff being entered
if(!empty($_POST['project'])){
$_SESSION['project_id']=insert("tbl_project",$field_list_2);
echo '<html><head>'.
'<META HTTP-EQUIV="REFRESH" CONTENT="1;URL=display_project_details.php?project_id='.$_SESSION['project_id'].'">'.
'New project added.</body></html>';
die;
}
//unset($_SESSION['project_id']);
//unset($_SESSION['project']);
if(!isset($_POST['reset'])){
$sql='SELECT * FROM tbl_project LEFT JOIN tbl_project_details ON tbl_project.project_id = tbl_project_details.project_id WHERE tbl_project_details.project_id='.$_SESSION['project_id'];
$row = mysql_fetch_assoc(query($sql));
}
$tab=0;
//Starts form
echo '<html><body>'.
'<form id="frm1" name="display_project_details" action="display_project_details.php" method=post>'.
textbox_list("","hidden","project_id",$_SESSION['project_id'],0,$tab++).
'<ol>'.
'<fieldset class="submit">'.
btn_new_save().
'</fieldset>'.
'<fieldset><legend>Project</legend>'.
textbox_list("Project","input","project",$row['project'],45,$tab++).
textbox_list("Name","input","project_desc",$row['project_desc'],45,$tab++).
textbox_list("AOA","input","aoa",$row['aoa'],45,45,$tab++).
textbox_list("Network Number","input","network_number",$row['network_number'],255,$tab++).
'</fieldset>'.
'<fieldset><legend>Customers</legend>'.
dropdown("Site Owner","company","company_id","company","tbl_company",$row['owner'],$tab++).
dropdown("Customer","company","company_id","company","tbl_company",$row['customer'],$tab++).
dropdown("Consultant","company","company_id","company","tbl_company",$row['consultant'],$tab++).
'</fieldset>'.
'<fieldset><legend>Shipping</legend>'.
dropdown("INCO Term","inco","inco","inco","tbl_list_inco_terms",$row['inco_term'],$tab++).
textbox_list("Named Place","input","inco_place",$row['inco_place'],45,$tab++).
textbox_list("RDD","input","rdd",$row['rdd'],45,$tab++).
textbox_list("Float","input","float",$row['float'],45,$tab++).
textbox_list("Transit Time","input","transit_time",$row['transit_time'],45,$tab++).
textbox_list("Ship Date","input","ship_date",$row['ship_date'],45,$tab++).
'</fieldset>'.
'<fieldset><legend>URL Addresses</legend>'.
textbox_list("Workflow","input","work_flow",$row['work_flow'],255,$tab++).
textbox_list("Documentum","input","documentum",$row['documentum'],255,$tab++).
textbox_list("Transfer to Service","input","xfer_service",$row['xfer_service'],255,$tab++).
textbox_list("PDIT","input","pdit",$row['pdit'],255,$tab++).
textbox_list("Service Request","input","service_request",$row['service_request'],255,$tab++).
'</fieldset>'.
'<fieldset><legend>Warranty</legend>'.
textbox_list("Accepted","input","wt_accept",$row['wt_accept'],45,$tab++).
textbox_list("Shipped","input","wt_ship",$row['wt_ship'],45,$tab++).
'</fieldset>'.
'<fieldset><legend>Document Transmittals</legend>'.
textbox_list("CD","input","st_cd",$row['st_cd'],45,$tab++).
textbox_list("Courier","input","st_courier",$row['st_courier'],45,$tab++).
textbox_list("email","input","st_email",$row['st_email'],45,$tab++).
textbox_list("FTP","input","st_ftp",$row['st_ftp'],45,$tab++).
textbox_list("Review Period","input","review_period",$row['review_period'],45,$tab++).
textbox_list("Submitting Office","input","submit_office",$row['submit_office'],45,$tab++).
textbox_list("Document Leveling","input","document_level",$row['document_level'],45,$tab++).
'</fieldset>'.
'<fieldset><legend>Variation Costing</legend>'.
checkbox("Margin Leveling","margin_level",$row['margin_level'],$tab++).
textbox_list("Contingency","input","contigency",$row['contigency'],45,$tab++).
textbox_list("Finacials","input","financials",$row['financials'],45,$tab++).
'</fieldset>'.
'</ol>'.
'</form>'.
'</body></html>';
?>