jeudi 26 février 2015

Writing to Access Database and Html Form From Another Form

I'm fairly new to html/php and am having issues on a project I am working on. Basically, I have an html form that writes to an Access database, which I have finished and works perfectly. However, the issue I am running into, is having the data submitted by the form read into another html form with a table automatically. I have been stuck for awhile and no amount of researching is helping. Any suggestions would be greatly appreciated. Thanks in advance guys.


Form that submits to Database





<html>
<head>
<title>HotPart Tracker </title>
</head>


<form method="post" action="newhotpartgenerate.php" name="frmhot" onsubmit="checkform(event)">

<ul>

<li >
<label><b>Timeframe Status: </b> </label> <br/>
<select name="status" style="WIDTH: 160px; HEIGHT: 20px" type="text">
<option value="" selected="selected"></option>
<option value="Critical" style="background-color:#FF0000">Critical (<30Min)</option>
<option value="Urgent"> Urgent (<1 Hour) </option>
<option value="Not a Priority" >Not a Priority (<2 Hours) </option>
</select>
</li>

<li >
<label><b>Line: </b></label> <br/>
<select name="line" style="WIDTH: 160px; HEIGHT: 20px" type="text">
<option value="" selected="selected"></option>
<option value="1" >1</option>
<option value="2" >2</option>
<option value="3" >3</option>
<option value="4" >4</option>
<option value="5" >5</option>
<option value="A" >A</option>
<option value="B" >B</option>
<option value="CB" >CB</option>
<option value="Control Box" >Tube Fab</option>
<option value="PPM" >PPM</option>
<option value="Repair" >Repair</option>
<option value="Tube Fab" >Tube Fab</option>
<option value="Warehouse" >Warehouse</option>
</select> <br/></li>


<script type="text/javascript">
function othercheck() {
if (document.getElementById('otheryes').selected) {
document.getElementById('otherspec').style.display = 'block';
} else {
document.getElementById('otherspec').style.display = 'none';
}
}
</script>

<div id="reasoncheck">
<li>
<label><b>Reason: </b> </label> <br/>
<select name="reason" style="WIDTH: 160px; HEIGHT: 20px" type="text" onclick="othercheck()";>
<option value="" selected="selected"></option>
<option value="No Materials Line Side" >No Materials Line Side</option>
<option value="Skip" >Skip</option>
<option value="Insertion" >Insertion</option>
<option value="Damaged" >Damaged</option>
<option value="Misidentified" >Misidentified</option>
<option value="Other" id="otheryes" > Other(Please Specify)</option>
</select>
<br/></li>
</div>

<div id="otherspec" style="display:none">
<li>
<label><b>Please Specify: </b></label><br/>
<textarea name="other" maxlength="300" class="element"" textarea small"></textarea>
<br/></li>
</div>



<li >
<div style="line-height:1em;">
<label> <b>Number Needed: </b> </label></br>
<input type="text" size="2" maxlength="4" name="numparts"> &nbsp; of &nbsp;
<select name="partcategory" style="WIDTH: 76px; HEIGHT: 20px" type="text">
<option value="" selected="selected"></option>
<option value="EA">EA</option>
<option value="Boxes" >Box(es)</option>
<option value="Pallets">Pallet(s)</option>
</select>
</div></li>


<li >
<div style="line-height:1em;">
<label> <b>Part Number:</b> </label> </br>
<input type="text" size="15" maxlength="12" name="partnum"> <br/> </div></li>


<li >
<div style="line-height:1em;">
<label> <b> Badge Scan:</b> </label> </br>
<input type="text" size="15" maxlength="9" name="badgescan"> <br/> </div></li> </br>



<script type="text/javascript">
function yesnoCheck() {
if (document.getElementById('yescheck').checked) {
document.getElementById('IfYes').style.display = 'block';
} else {
document.getElementById('IfYes').style.display = 'none';
}
}
</script>

<li >
<label><b>Is Line Currently Down? </b></label> <br/>
<input type="radio" onclick="yesnoCheck();" name="linestop" value="Yes" id="yescheck" >Yes <br/>
<input type="radio" onclick="yesnoCheck();" name="linestop" value="No" id="nocheck" checked="checked" >No
</li>


<div id="IfYes" style="display:none">





<div style="line-height:2em;">
<li>
<label><b>Time Down: </b></label>
<input type="text" size="1" maxlength="2" name="timedownhour"> :
<input type="text" size="1" maxlength="2" name="timedownminute">
<select class="element select" style="width:4em" id="element_2_5" name="timedownampm">
<option value="AM" >AM</option>
<option value="PM" >PM</option>
</select>
<label><b>AM/PM</b></label><br/>
</li>
</div>

</div>

</ul>




<script type="text/javascript">
function checkform(evt) {
var myForm = document.frmhot;
var condition = true;
if(myForm.status.value==""){
alert("Please select a timeframe status.");
myForm.status.focus();
condition = false;
}
if (myForm.line.value==""){
alert("Please select a line.");
condition = false;
}
if(myForm.reason.value==""){
alert("Please select a reason code.");
condition = false;
}
if(myForm.partnum.value==""){
alert("Please enter a part number.");
condition = false;
}
if(myForm.badgescan.value==""){
alert("Please enter a badge number.");
condition = false;
}
if(condition){ condition = confirm('Do you want to submit the form?'); }

if(!condition) {
if(evt.preventDefault) { event.preventDefault(); }
else if(evt.returnValue) { evt.returnValue = false; }
else { return false; }
}
}
</script>



<input class="button_text" type="submit" value="Submit" name="submit" />
</form>






<style type="text/css"> /*Initializing CSS code*/
img {
position: absolute;
bottom:10px;
right: 10px;
}
</style>
</body>
</html>



Php To Connect and Write to Database





<html>
<body>



<?php


date_default_timezone_set('America/Chicago');
$realtime = date('m/d/Y h:i:s a', time());

$status=$_POST['status'];
$line=$_POST['line'];
$reason=$_POST['reason'];
$numparts=$_POST['numparts'];
$partcategory=$_POST['partcategory'];
$partnum=$_POST['partnum'];
$badgescan=$_POST['badgescan'];
$linestop=$_POST['linestop'];

$_SESSION['line']=$line;
?>
<script style="text/javascript">


</script>
<?php

$dbname='';
if (!file_exists($dbname)) {
die("Could not find database file.");
}
$db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$dbname; Uid=''; Pwd='';");

if($cnx=odbc_connect('hotpartodbc', 'root', ''))
{
}
else{
?><script type="text/javascript">
alert(Connection failed)
</script><?php
}

$sql= "INSERT INTO HotPartLog ([Date], Status, Line, Reason, [Number of Parts], [Part Number], Badge, [Line Down Time]) VALUES ('$realtime', '$status','$line', '$reason', '$numparts', '$partnum','$badgescan', '$linestop')";

$cur=odbc_exec( $cnx, $sql);
odbc_close($cnx);
?>




<form action="newreceivinghotpart.php" name="confirm" >
<input class="button_text" type="submit" value="Return to Page" name="submit" />
</form>

</body>
</html>



Second Html Form I Would Like to Populate





<html>

<h1><font color="FF6600"> In Progress </font></h1>
<body>


<!----<?php
include('C:\xampp\htdocs\Sean\New\newhotpartgenerate.php');
?>--->



<div class="datagrid">
<table cellpadding="0" cellspacing="0" name="InProgTable">
<thead>
<tr>
<th class="remove-whitespace">Action</th>
<th>Time</th>
<th>Line</th>
<th>Quantity</th>
<th>Operator</th>
<th>test</th>
<th>test</th>
</tr>
</thead>

<tbody>
<col width="100px"
<tr>
<td width= "10%" align="left" class="no-padding" >
<select name="action" style="WIDTH: 100px; HEIGHT: 20px" type="text" cellpadding="0" cellspacing="0">
<option value="" selected="selected"></option>
<option value="Closed" style="background-color:#66FF66">Closed</option>
<option value="In Progress" style="background-color:#FF0000">In Progress</option>
</select>
</td>

<td width= "10%" align="left" class="no-padding" ><?php echo $realtime ?></td>
<td width= "10%" align="left" class="no-padding" ><?php echo $line ?></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</col>


</tbody>
</table>
</div>



<form>
<input class="button_text" type="submit" value="Delete Closed Rows">





<style type="text/css">
.datagrid table {
border-collapse: collapse;
text-align: left;
table-layout: fixed;
width: 100%;
}
.datagrid {
font: normal 12px/150% Arial, Helvetica, sans-serif;
background: #fff;
overflow: hidden;
border: 2px solid #FA940F;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.datagrid table td,
.datagrid table th {
padding: 4px 4px;
}
.datagrid table thead th {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #FA921B), color-stop(1, #FF3526));
background: -moz-linear-gradient(center top, #FA921B 5%, #FF3526 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#FA921B', endColorstr='#FF3526');
background-color: #FA921B;
color: #FFFFFF;
font-size: 14px;
font-weight: bold;
border-left: 1px solid #F2C530;
}
.datagrid table thead th:first-child {
border: none;
}
.datagrid table tbody td {
color: #000305;
border-left: 1px solid #F2791D;
font-size: 12px;
font-weight: normal;
}
.datagrid table tbody .alt td {
background: #FFDBA6;
color: #090F07;
}
.datagrid table tbody td:first-child {
border-left: none;
}
.datagrid table tbody tr:last-child td {
border-bottom: none;
}
.datagrid table td.no-padding { padding: 0; }
.remove-whitespace { width: 154px; }
</style>

</body>

</html>



Aucun commentaire:

Enregistrer un commentaire