我有一个问题,我想让它检查用户是否提交了一个带有dept键的数据,比如dept Outbound将是键O和今天的日期,以便第二天用户可以再次输入数据。我不确定这将如何实现。
这是创建表单
<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Create Form</title>
<script type="text/javascript" src="Javascript/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="Javascript/autocompleteAreaCode.js"></script>
<script type="text/javascript" src="Javascript/autocompletedeptkey.js"></script>
<script type="text/javascript" src="Javascript/validator.js"></script>
<link href="css/default.css" rel="stylesheet" type="text/css" >
</head>
<body style="background-image: url('images/background.jpg')">
<form action = "insert_process.php" onsubmit="return validateForm()" name="form" id="form" method ="post" class="style1" style="width: 1125px; height: 800px; margin-top: 30px; margin-left:0px;">
<table align="center" id="tfhover" class="tftable" border="1">
<br><br>
<tr>
<td colspan="7"><h1 align="center">Lighting Schedule Form</h1></td>
</tr>
<tr>
<th>Department</th><th style="width: 75px">Area Code</th><th style="width: 144px">Off Time</th><th>Grave Yard On Time</th><th>First Shift OnTime</th><th width="125px">Comments Or Date By</th><th>Initials</th></tr>
<tr>
<!--First row accross on the table-->
<td><select name="Department" id="Department" >
<option value ="">Please select ...</option>
<option value ="Upstairs Hang East">Upstairs Hang East</option>
<option value ="Upstairs Hang West">Upstairs Hang West</option>
<option value ="RDR">RDR</option>
<option value ="Hang Sortation">Hang Sortation</option>
<option value ="RACK WAREHOUSE">RACK WAREHOUSE</option>
<option value ="Hang To Flat">HANG TO FLAT</option>
<option value ="RACK SHOES">RACK SHOES</option>
<option value ="FLAT 2">FLAT 2</option>
<option value ="FLAT 1">FLAT 1</option>
<option value ="Claims">Claims</option>
<option value ="INBOUND">INBOUND</option>
<option value ="OUTBOUND">OUTBOUND</option>
</select></td>
<td style="width: 75px"><input id="areaCode" name="areaCode" onkeydown="return false;" type="text"/></td>
<td style="width: 144px"><input class="offtime" id="offtime" name="offtime" type="text" /></td>
<td><input id="gytime" name="gytime" type="text" /></td>
<td><input id="ftime" name="ftime" type="text" /></td>
<td><input id="comments" name="comments" type="text" style="width: 139px" /></td>
<td><input id="ini" name="ini" type="text" style="width: 68px" /></td>
</tr>
<input id="deptkey" name="deptkey" onkeydown="return false;" type="hidden"/>
<!--end of first row-->
<tr>
<!--First row accross on the table-->
<td><select name="Department2" id="Department2" >
<option value ="">Please select ...</option>
<option value ="Upstairs Hang East">Upstairs Hang East</option>
<option value ="Upstairs Hang West">Upstairs Hang West</option>
<option value ="RDR">RDR</option>
<option value ="Hang Sortation">Hang Sortation</option>
<option value ="RACK WAREHOUSE">RACK WAREHOUSE</option>
<option value ="Hang To Flat">HANG TO FLAT</option>
<option value ="RACK SHOES">RACK SHOES</option>
<option value ="FLAT 2">FLAT 2</option>
<option value ="FLAT 1">FLAT 1</option>
<option value ="Claims">Claims</option>
<option value ="INBOUND">INBOUND</option>
<option value ="OUTBOUND">OUTBOUND</option>
</select></td>
<td style="width: 75px"><input id="areaCode2" name="areaCode2" onkeydown="return false;" type="text"/></td>
<td style="width: 144px"><input class="offtime2" id="offtime2" name="offtime2" type="text" /></td>
<td><input id="gytime2" name="gytime2" type="text" /></td>
<td><input id="ftime2" name="ftime2" type="text" /></td>
<td><input id="comments2" name="comments2" type="text" style="width: 139px" /></td>
<td><input id="ini2" name="ini2" type="text" style="width: 68px" /></td>
</tr>
<input id="deptkey2" name="deptkey2" type="hidden"/>
<!--end of first row-->
<tr>
<!--First row accross on the table-->
<td><select name="Department3" id="Department3" >
<option value ="">Please select ...</option>
<option value ="Upstairs Hang East">Upstairs Hang East</option>
<option value ="Upstairs Hang West">Upstairs Hang West</option>
<option value ="RDR">RDR</option>
<option value ="Hang Sortation">Hang Sortation</option>
<option value ="RACK WAREHOUSE">RACK WAREHOUSE</option>
<option value ="Hang To Flat">HANG TO FLAT</option>
<option value ="RACK SHOES">RACK SHOES</option>
<option value ="FLAT 2">FLAT 2</option>
<option value ="FLAT 1">FLAT 1</option>
<option value ="Claims">Claims</option>
<option value ="INBOUND">INBOUND</option>
<option value ="OUTBOUND">OUTBOUND</option>
</select></td>
<td style="width: 75px"><input id="areaCode3" name="areaCode3" onkeydown="return false;" type="text"/></td>
<td style="width: 144px"><input class="offtime3" id="offtime3" name="offtime3" type="text" /></td>
<td><input id="gytime3" name="gytime3" type="text" /></td>
<td><input id="ftime3" name="ftime3" type="text" /></td>
<td><input id="comments3" name="comments3" type="text" style="width: 139px" /></td>
<td><input id="ini3" name="ini3" type="text" style="width: 68px" /></td>
</tr>
<input id="deptkey3" name="deptkey3" onkeydown="return false;" type="hidden"/>
<!--end of first row-->
<tr>
<!--First row accross on the table-->
<td><select name="Department4" id="Department4" >
<option value ="">Please select ...</option>
<option value ="Upstairs Hang East">Upstairs Hang East</option>
<option value ="Upstairs Hang West">Upstairs Hang West</option>
<option value ="RDR">RDR</option>
<option value ="Hang Sortation">Hang Sortation</option>
<option value ="RACK WAREHOUSE">RACK WAREHOUSE</option>
<option value ="Hang To Flat">HANG TO FLAT</option>
<option value ="RACK SHOES">RACK SHOES</option>
<option value ="FLAT 2">FLAT 2</option>
<option value ="FLAT 1">FLAT 1</option>
<option value ="Claims">Claims</option>
<option value ="INBOUND">INBOUND</option>
<option value ="OUTBOUND">OUTBOUND</option>
</select></td>
<td style="width: 75px"><input id="areaCode4" name="areaCode4" onkeydown="return false;" type="text"/></td>
<td style="width: 144px"><input class="offtime4" id="offtime4" name="offtime4" type="text" /></td>
<td><input id="gytime4" name="gytime4" type="text" /></td>
<td><input id="ftime4" name="ftime4" type="text" /></td>
<td><input id="comments4" name="comments4" type="text" style="width: 139px" /></td>
<td><input id="ini4" name="ini4" type="text" style="width: 68px" /></td>
</tr>
<td><input id="deptkey4" name="deptkey4" type="text"/></td>
<!--end of first row-->
<!--start of the weekend section-->
<tr>
<td colspan="7"><h1 align="center">Weekend Scheduling Request</h1></td>
</tr>
<tr>
<th>Department</th><th style="width: 75px">Saturday On Time</th><th style="width: 144px">Saturday Off Time</th><th>Comments or Date By</th><th>Signature</th></tr>
<tr>
<td><select name="sat_ob_department" id="sat_ob_department" >
<option value ="">Please select ...</option>
<option value ="Upstairs Hang East">Upstairs Hang East</option>
<option value ="Upstairs Hang West">Upstairs Hang West</option>
<option value ="RDR">RDR</option>
<option value ="Hang Sortation">Hang Sortation</option>
<option value ="RACK WAREHOUSE">RACK WAREHOUSE</option>
<option value ="Hang To Flat">HANG TO FLAT</option>
<option value ="RACK SHOES">RACK SHOES</option>
<option value ="FLAT 2">FLAT 2</option>
<option value ="FLAT 1">FLAT 1</option>
<option value ="Claims">Claims</option>
<option value ="INBOUND">INBOUND</option>
<option value ="OUTBOUND">OUTBOUND</option>
</select></td>
<td style="width: 75px"><input id="sat_ob_onTime" name="sat_ob_onTime" type="text" /></td>
<td style="width: 144px"><input class="sat_ob_offTime" id="sat_ob_offTime" name="time" type="text" /></td>
<td><input id="ob_comments" name="ob_comments" type="text" /></td>
<td><input id="ob_signature" name="ob_signature" type="text" /></td>
</tr>
<tr>
<td><select name="sat_ib_department" id="sat_ib_department" >
<option value ="">Please select ...</option>
<option value ="Upstairs Hang East">Upstairs Hang East</option>
<option value ="Upstairs Hang West">Upstairs Hang West</option>
<option value ="RDR">RDR</option>
<option value ="Hang Sortation">Hang Sortation</option>
<option value ="RACK WAREHOUSE">RACK WAREHOUSE</option>
<option value ="Hang To Flat">HANG TO FLAT</option>
<option value ="RACK SHOES">RACK SHOES</option>
<option value ="FLAT 2">FLAT 2</option>
<option value ="FLAT 1">FLAT 1</option>
<option value ="Claims">Claims</option>
<option value ="INBOUND">INBOUND</option>
<option value ="OUTBOUND">OUTBOUND</option>
</select></td>
<td style="width: 75px"><input id="sat_ib_onTime" name="sat_ib_onTime" type="text" /></td>
<td style="width: 144px"><input class="sat_ib_offTime" id="sat_ib_offTime" name="time" type="text" /></td>
<td><input id="ib_comments" name="ib_comments" type="text" /></td>
<td><input id="ib_signature" name="ib_signature" type="text" /></td>
</tr>
</table>
<div><br><p align="center"><input type="submit" value= "Submit Request "></p></div>
<input type="hidden" value ="<?php echo date("m/d/Y",time())?>"name="Requestdate" id="Requestdate">
</form>
</body>
</html>
插入_进程.php
<?php
$serverName = "localhost";
$db= new PDO( "sqlsrv:server=$serverName ; Database=lightingschedule", "test", "test");
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$stmt= $db->prepare("INSERT INTO tbl_lighting(Department,
areaCode, offtime, gytime, ftime, ini,
sat_ob_department, sat_ib_department,
sat_ob_onTime,sat_ib_onTime,
sat_ob_offTime, sat_ib_offTime,
ob_signature,ib_signature,
deptkey, comments,ib_comments,ob_comments,Requestdate
) Values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$stmt->bindParam(1, $_POST["Department"]);
$stmt->bindParam(2, $_POST["areaCode"]);
$stmt->bindParam(3, $_POST["offtime"]);
$stmt->bindParam(4, $_POST["gytime"]);
$stmt->bindParam(5, $_POST["ftime"]);
$stmt->bindParam(6, $_POST["ini"]);
$stmt->bindParam(7, $_POST["sat_ob_department"]);
$stmt->bindParam(8, $_POST["sat_ib_department"]);
$stmt->bindParam(9, $_POST["sat_ob_onTime"]);
$stmt->bindParam(10, $_POST["sat_ib_onTime"]);
$stmt->bindParam(11, $_POST["sat_ob_offTime"]);
$stmt->bindParam(12, $_POST["sat_ib_offTime"]);
$stmt->bindParam(13, $_POST["ob_signature"]);
$stmt->bindParam(14, $_POST["ib_signature"]);
$stmt->bindParam(15, $_POST["deptkey"]);
$stmt->bindParam(16, $_POST["comments"]);
$stmt->bindParam(17, $_POST["ib_comments"]);
$stmt->bindParam(18, $_POST["ob_comments"]);
$stmt->bindParam(19, $_POST["Requestdate"]);
$stmt->execute();
if ( $_POST['Department2']=!'' )
{
$stmt= $db->prepare("INSERT INTO tbl_lighting(Department,
areaCode, offtime, gytime, ftime, ini,
sat_ob_department, sat_ib_department,
sat_ob_onTime,sat_ib_onTime,
sat_ob_offTime, sat_ib_offTime,
ob_signature,ib_signature,
deptkey, comments,ib_comments,ob_comments,Requestdate
) Values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$stmt->bindParam(1, $_POST["Department2"]);
$stmt->bindParam(2, $_POST["areaCode2"]);
$stmt->bindParam(3, $_POST["offtime2"]);
$stmt->bindParam(4, $_POST["gytime2"]);
$stmt->bindParam(5, $_POST["ftime2"]);
$stmt->bindParam(6, $_POST["ini2"]);
$stmt->bindParam(7, $_POST["sat_ob_department"]);
$stmt->bindParam(8, $_POST["sat_ib_department"]);
$stmt->bindParam(9, $_POST["sat_ob_onTime"]);
$stmt->bindParam(10, $_POST["sat_ib_onTime"]);
$stmt->bindParam(11, $_POST["sat_ob_offTime"]);
$stmt->bindParam(12, $_POST["sat_ib_offTime"]);
$stmt->bindParam(13, $_POST["ob_signature"]);
$stmt->bindParam(14, $_POST["ib_signature"]);
$stmt->bindParam(15, $_POST["deptkey2"]);
$stmt->bindParam(16, $_POST["comments2"]);
$stmt->bindParam(17, $_POST["ib_comments"]);
$stmt->bindParam(18, $_POST["ob_comments"]);
$stmt->bindParam(19, $_POST["Requestdate"]);
$stmt->execute();
}
if ( $_POST['Department3']=!'' )
{
$stmt= $db->prepare("INSERT INTO tbl_lighting(Department,
areaCode, offtime, gytime, ftime, ini,
sat_ob_department, sat_ib_department,
sat_ob_onTime,sat_ib_onTime,
sat_ob_offTime, sat_ib_offTime,
ob_signature,ib_signature,
deptkey, comments,ib_comments,ob_comments,Requestdate
) Values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$stmt->bindParam(1, $_POST["Department3"]);
$stmt->bindParam(2, $_POST["areaCode3"]);
$stmt->bindParam(3, $_POST["offtime3"]);
$stmt->bindParam(4, $_POST["gytime3"]);
$stmt->bindParam(5, $_POST["ftime3"]);
$stmt->bindParam(6, $_POST["ini3"]);
$stmt->bindParam(7, $_POST["sat_ob_department"]);
$stmt->bindParam(8, $_POST["sat_ib_department"]);
$stmt->bindParam(9, $_POST["sat_ob_onTime"]);
$stmt->bindParam(10, $_POST["sat_ib_onTime"]);
$stmt->bindParam(11, $_POST["sat_ob_offTime"]);
$stmt->bindParam(12, $_POST["sat_ib_offTime"]);
$stmt->bindParam(13, $_POST["ob_signature"]);
$stmt->bindParam(14, $_POST["ib_signature"]);
$stmt->bindParam(15, $_POST["deptkey3"]);
$stmt->bindParam(16, $_POST["comments3"]);
$stmt->bindParam(17, $_POST["ib_comments"]);
$stmt->bindParam(18, $_POST["ob_comments"]);
$stmt->bindParam(19, $_POST["Requestdate"]);
$stmt->execute();
}
if ( $_POST['Department4']=!'' )
{
$stmt= $db->prepare("INSERT INTO tbl_lighting(Department,
areaCode, offtime, gytime, ftime, ini,
sat_ob_department, sat_ib_department,
sat_ob_onTime,sat_ib_onTime,
sat_ob_offTime, sat_ib_offTime,
ob_signature,ib_signature,
deptkey, comments,ib_comments,ob_comments,Requestdate
) Values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$stmt->bindParam(1, $_POST["Department4"]);
$stmt->bindParam(2, $_POST["areaCode4"]);
$stmt->bindParam(3, $_POST["offtime4"]);
$stmt->bindParam(4, $_POST["gytime4"]);
$stmt->bindParam(5, $_POST["ftime4"]);
$stmt->bindParam(6, $_POST["ini4"]);
$stmt->bindParam(7, $_POST["sat_ob_department"]);
$stmt->bindParam(8, $_POST["sat_ib_department"]);
$stmt->bindParam(9, $_POST["sat_ob_onTime"]);
$stmt->bindParam(10, $_POST["sat_ib_onTime"]);
$stmt->bindParam(11, $_POST["sat_ob_offTime"]);
$stmt->bindParam(12, $_POST["sat_ib_offTime"]);
$stmt->bindParam(13, $_POST["ob_signature"]);
$stmt->bindParam(14, $_POST["ib_signature"]);
$stmt->bindParam(15, $_POST["deptkey4"]);
$stmt->bindParam(16, $_POST["comments4"]);
$stmt->bindParam(17, $_POST["ib_comments"]);
$stmt->bindParam(18, $_POST["ob_comments"]);
$stmt->bindParam(19, $_POST["Requestdate"]);
$stmt->execute();
}
?>
<h1 align="center">Successfully Entered!</h1>