这是我的代码,基本上是它的编写,所以你需要做的就是点击提交。我收到了一个错误:
数据未发布。我不明白为什么。在任何想象中我都不是主编,但我认为我的一切都是正确的。有人能指出我正确的方向吗?
由于
<?php
require_once('connectvars.php');
?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>PDI Non-Conforming Materials Report</title>
<link rel="stylesheet" type="text/css" href="CSS/postie.css" />
</head>
<body>
<div id="logo">
<img src="images/PDI_Logo_2.1.gif" alt="PDI Logo" />
</div>
<div id="title">
<h3 id="NCMR2">Non-Conforming Materials Report (NCMR)</h3>
</div>
<?php
//Post Data
if (isset($_POST['submit'])) {
$ab = $_POST['ab'];
$date = date('Y-m-d',strtotime($_POST['date']));
$part = $_POST['part'];
$rev = $_POST['rev'];
$partdesc = $_POST['partdesc'];
$ncmrqty = $_POST['ncmrqty'];
$comp = $_POST['comp'];
$ncmrid = $_POST['ncmrid'];
$rma = $_POST['rma'];
$jno = $_POST['jno'];
$in = $_POST['in'];
$tp = $_POST['tp'];
$cof = $_POST['cof'];
$fab1= $_POST['fab1'];
$fab2= $_POST['fab2'];
$fab3= $_POST['fab3'];
$non= $_POST['non'];
$dis= $_POST['dis'];
$comm= $_POST['comm'];
$caad= $_POST['caad'];
$po= $_POST['po'];
$pod = date('Y-m-d',strtotime($_POST['pod']));
$dri = date('Y-m-d',strtotime($_POST['dri']));
$output_form = 'no';
if (empty($ab) || empty($date) || empty($part) || empty($partdesc) || empty($ncmrid) || empty($non) || empty($dis) || empty($po) || empty($pod) || empty($dri)) {
// We know at least one of the input fields is blank
echo 'Please fill out all of the required NCMR information.<br />';
$output_form = 'yes';
}
}
else {
$output_form = 'yes';
}
//Access the Database
if (!empty($ab) && !empty($date) && !empty($pod)) {
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
or die('Error connecting to MySQL server.');
$query = "INSERT INTO ncmr (ab, date, part, rev, partdesc, ncmrqty, comp, ncmrid, rma, jno, in, tp, cof, fab1, fab2, fab3, non, dis, comm, caad, po, pod, dri)
VALUES ('$ab', '$date', '$part', '$rev', '$partdesc', '$ncmrqty', '$comp', '$ncmrid', '$rma', '$jno', '$in', '$tp', '$cof', '$fab1', '$fab2', '$fab3', '$non', '$dis', '$comm', '$caad', '$po', '$pod', '$dri')";
mysqli_query($dbc, $query)
or die ('Data not inserted.');
// Confirm success with the user
echo '<tr><td class="thank">';
echo '<p>Thank you for adding the NCRM, the correct person will be informed.</p>';
echo '<p><a href="post.php"><< Back to the form</a></p>';
echo '</td></tr>';
mysqli_close($dbc);
}
if ($output_form == 'yes') {
echo '<form method="post">';
echo '<fieldset>';
//Part, Rev, Part Description, NCMR Qty
echo '<div id="box1">';
echo '<div id="ab"><span class="b">Added By: </span><input type="text" name="ab" value="" /></div>';
echo '<div id="date"><span class="b">Date Filed: </span><input type="text" name="date" value="" /></div>';
echo '<div id="part"><span class="b">Part Number: </span><input type="text" name="part" value="" /></div>';
echo '<div id="rev"><span class="b">Part Revision: </span><input type="text" name="rev" value="" /></div>';
echo '<div id="partdesc"><span class="b">Part Description: </span><textarea name="partdesc" rows="3" cols="22" ></textarea></div>';
echo '<div id="ncmrqty"><span class="b">NCMR Qty: </span><input type="text" name="ncmrqty" value="" /></div>';
echo '</div>';
//Inventory On Hand, Inventory Check, Supplier Name, Supplier Number, Manufacturer Part Number, Manufactuer Serial Number and NCMR ID
echo '<div id="box2">';
echo'<div id="comp">';
echo '<span class="b">Company: </span>';
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$mysqli->select_db('comp');
$result = $mysqli->query("SELECT * FROM comp");
$i = 0;
echo "<SELECT name='comp'>\n";
while($row = $result->fetch_assoc()) {
if ($i == 3) echo '<option value="lines">-----</option>';
echo "<option value='{$row['user_id']}'>{$row['name']}</option>\n";
$i++;
}
echo "</select>\n";
echo '</div>';
echo '<div id="ncmrid"><span class="b">Customer NCMR ID: </span><input type="text" name="ncmrid" value="" /></div>';
echo '<div id="rma"><span class="b">Internal RMA #: </span><input type="text" name="rma" value="" /></div>';
echo '<div id="jno"><span class="b">Job #: </span><input type="text" name="jno" value="" /></div>';
echo '</div>';
//Type of Failure and Class of Failure
echo '<div id="box3">';
echo '<h2>Failure Due To</h2>';
echo '<input type="hidden" name="ih" value="0" /><br />';
echo '<input type="checkbox" name="ih" value="1" /> In House<br />';
echo '<input type="hidden" name="tp" value="0" /><br />';
echo '<input type="checkbox" name="tp" value="1" /> Third Party<br />';
echo'<div id="cof">';
echo '<span class="b">Class of Failure: </span><br />';
echo '<select name="cof">';
echo '<option value="none">----None----</option>';
echo '<option value="Materials">Materials</option>';
echo '<option value="Fabrication">Fabrication</option>';
echo '<option value="Drawing">Drawing</option>';
echo '<option value="Assembly">Assembly</option>';
echo '<option value="Testing">Testing</option>';
echo '<option value="Electrical">Electrical</option>';
echo '<option value="Programming">Programming</option>';
echo '<option value="Machining">Machining</option>';
echo '<option value="Inspection">Inspection</option>';
echo '<option value="Purchasing">Purchasing</option>';
echo '<option value="Administrator">Administrator</option>';
echo '</select>';
echo '</div>';
echo '</div>';
//Fabricators
echo '<div id="box4">';
echo '<h2>Fabricators</h2>';
echo'<div id="fab1">';
echo '<select name="fab1">';
echo '<option value="none">===None===</option>';
echo '<option value="Andy Kahl">Andy Kahl</option>';
echo '<option value="Anthony Ayoub">Anthony Ayoub</option>';
echo '<option value="Bob Payne">Bob Payne</option>';
echo '<option value="Butch Laplante">Butch Laplante</option>';
echo '<option value="Daryl Flynn">Daryl Flynn</option>';
echo '<option value="Derrick Clark">Derrick Clark</option>';
echo '<option value="Dolores Drinkwater">Dolores Drinkwater</option>';
echo '<option value="Errol Flynn">Errol Flynn</option>';
echo '<option value="Gary Capella">Gary Capella</option>';
echo '<option value="Gelia Moril">Gelia Moril</option>';
echo '<option value="Gregg Tansino">Gregg Tansino</option>';
echo '<option value="Kevin Sullivan">Kevin Sullivan</option>';
echo '<option value="Kurt Flynn">Kurt Flynn</option>';
echo '<option value="Matt Ross">Matt Ross</option>';
echo '<option value="Mike Sullivan">Mike Sullivan</option>';
echo '<option value="Patrick Walsh">Patrick Walsh</option>';
echo '<option value="Ralph Block">Ralph Block</option>';
echo '<option value="Rick Guay">Rick Guay</option>';
echo '<option value="Scott Hamel">Scott Hamel</option>';
echo '<option value="Scott King">Scott King</option>';
echo '<option value="Scott Pazerbiak">Scott Pazerbiak</option>';
echo '<option value="Scott Zizza">Scott Zizza</option>';
echo '<option value="Shaun Tardiff">Shaun Tardiff</option>';
echo '<option value="Sherry Ryan">Sherry Ryan</option>';
echo '<option value="Terry Wilkins">Terry Wilkins</option>';
echo '<option value="Wade Page">Wade Page</option>';
echo '</select>';
echo '</div>';
echo'<div id="fab2">';
echo '<select name="fab2">';
echo '<option value="none">===None===</option>';
echo '<option value="Andy Kahl">Andy Kahl</option>';
echo '<option value="Anthony Ayoub">Anthony Ayoub</option>';
echo '<option value="Bob Payne">Bob Payne</option>';
echo '<option value="Butch Laplante">Butch Laplante</option>';
echo '<option value="Daryl Flynn">Daryl Flynn</option>';
echo '<option value="Derrick Clark">Derrick Clark</option>';
echo '<option value="Dolores Drinkwater">Dolores Drinkwater</option>';
echo '<option value="Errol Flynn">Errol Flynn</option>';
echo '<option value="Gary Capella">Gary Capella</option>';
echo '<option value="Gelia Moril">Gelia Moril</option>';
echo '<option value="Gregg Tansino">Gregg Tansino</option>';
echo '<option value="Kevin Sullivan">Kevin Sullivan</option>';
echo '<option value="Kurt Flynn">Kurt Flynn</option>';
echo '<option value="Matt Ross">Matt Ross</option>';
echo '<option value="Mike Sullivan">Mike Sullivan</option>';
echo '<option value="Patrick Walsh">Patrick Walsh</option>';
echo '<option value="Ralph Block">Ralph Block</option>';
echo '<option value="Rick Guay">Rick Guay</option>';
echo '<option value="Scott Hamel">Scott Hamel</option>';
echo '<option value="Scott King">Scott King</option>';
echo '<option value="Scott Pazerbiak">Scott Pazerbiak</option>';
echo '<option value="Scott Zizza">Scott Zizza</option>';
echo '<option value="Shaun Tardiff">Shaun Tardiff</option>';
echo '<option value="Sherry Ryan">Sherry Ryan</option>';
echo '<option value="Terry Wilkins">Terry Wilkins</option>';
echo '<option value="Wade Page">Wade Page</option>';
echo '</select>';
echo '</div>';
echo'<div id="fab3">';
echo '<select name="fab3">';
echo '<option value="none">===None===</option>';
echo '<option value="Andy Kahl">Andy Kahl</option>';
echo '<option value="Anthony Ayoub">Anthony Ayoub</option>';
echo '<option value="Bob Payne">Bob Payne</option>';
echo '<option value="Butch Laplante">Butch Laplante</option>';
echo '<option value="Daryl Flynn">Daryl Flynn</option>';
echo '<option value="Derrick Clark">Derrick Clark</option>';
echo '<option value="Dolores Drinkwater">Dolores Drinkwater</option>';
echo '<option value="Errol Flynn">Errol Flynn</option>';
echo '<option value="Gary Capella">Gary Capella</option>';
echo '<option value="Gelia Moril">Gelia Moril</option>';
echo '<option value="Gregg Tansino">Gregg Tansino</option>';
echo '<option value="Kevin Sullivan">Kevin Sullivan</option>';
echo '<option value="Kurt Flynn">Kurt Flynn</option>';
echo '<option value="Matt Ross">Matt Ross</option>';
echo '<option value="Mike Sullivan">Mike Sullivan</option>';
echo '<option value="Patrick Walsh">Patrick Walsh</option>';
echo '<option value="Ralph Block">Ralph Block</option>';
echo '<option value="Rick Guay">Rick Guay</option>';
echo '<option value="Scott Hamel">Scott Hamel</option>';
echo '<option value="Scott King">Scott King</option>';
echo '<option value="Scott Pazerbiak">Scott Pazerbiak</option>';
echo '<option value="Scott Zizza">Scott Zizza</option>';
echo '<option value="Shaun Tardiff">Shaun Tardiff</option>';
echo '<option value="Sherry Ryan">Sherry Ryan</option>';
echo '<option value="Terry Wilkins">Terry Wilkins</option>';
echo '<option value="Wade Page">Wade Page</option>';
echo '</select>';
echo '</div>';
echo '</div>';
//Nonconformity, Disposition, Comments and Comments & Additional Details
echo '<div id="box5">';
echo '<div id="non"><span class="b">Nonconformity: </span><br /><textarea name="non" rows="3" cols="110" ></textarea><br /></div>';
echo '<div id="dis"><span class="b">Disposition: </span><br /><textarea name="dis" rows="3" cols="110" ></textarea></div>';
echo '<div id="comm"><span class="b">Comments: </span><br /><textarea name="comm" rows="3" cols="110" ></textarea></div>';
echo '<div id="caad"><span class="b">Comments and/or Additional Details: </span><br /><textarea name="caad" rows="3" cols="110" ></textarea></div>';
//PO, PO Date, and Date Recieved
echo '<div id="podr">';
echo '<div id="po"><span class="b">PO: </span><input type="text" name="po" size="7" value="" /></div>';
echo '<div id="pod"><span class="b">PO Date: </span><input type="text" name="pod" size="7" value="" /></div>';
echo '<div id="dri"><span class="b">Date Received: </span><input type="text" name="dri" size="7" value=""';
echo '</div>';
echo '<div id="button"><input type="submit" value="Submit NCMR" name="submit" /></div>';
echo '</div>';
echo '</fieldset>';
echo '</form>';
}
?>
</body>
</html>
答案 0 :(得分:1)
首先,您的表单没有设置ACTION
- 这就决定了数据的发送位置。
所以,改变一下:
echo '<form method="post">';
类似于:
echo '<form method="post" action="http://url.to/your_file.php">';
答案 1 :(得分:0)
您只为每个选项提供了值,但没有名称,这是要识别的帖子值的基本要求。
答案 2 :(得分:0)
通过给你这个
,我可以节省你很多时间<?
foreach ($_POST as $k=>$v) $$k=$v;
?>
以上代码将您的$ _POST变量移动到$ normal范围可以使用我上面的微小代码来完成。您的表单也存在严重错误