在我尝试添加此语句之前它一直有效
<?php echo "<input type=\"hidden\" name=\"hidden1\" value=\"$id\">" ?>
我之前能够从我的表单中获取 indexnum,但是当我添加该行时,字段中似乎没有加载任何内容。
这是完整的表格:
<form name="approveform" method="POST" action="">
<?php echo "<input type=\"hidden\" name=\"hidden1\" value=\"$id\">" ?>
Index Number*: <input type="text" name="IndexNum">
<input type="submit" value="Approve" action="">
</form>
时间不早了,我可能需要睡觉了,但我很近!!!这是处理 POST 的完整代码。
if($user_data['permissions'] >= 1)
{
// If users permission is 1 or 2 they get a field for inputting the index # and a button to change the approve field from 0 to 1 may need to make a new field to record who approved it....
//Determine if the order is already approved. If not approved show index field and allow user to approve it with index number
if($data2[0]['Approved'] == 1)
{
echo " <font color=\"green\"> Approved";
}
if($data2[0]['Approved'] == 0)
{
echo " Not Approved. Supply an index number and click approve to authorize this order to be completed.";
if (empty ($_POST) === false)
{
$required_fields = array('IndexNum');
foreach ($_POST as $key=>$value)
{
if (empty($value) && in_array($key, $required_fields) === true)
{
$errors[] = 'Fields marked with an asterisk are required';
break 1;
}
}
if (isset($_POST['success']) === true && empty($_POST['success']) === true)
{
echo 'Index has been updated and Order is now set to Approved';
}
else
{
if (empty($errors) === true)
{
$indexnum=$_POST['IndexNum'];
$approvedby=$user_data['lname'];
$vendorid1= $_POST['hidden1'];
echo $indexnum;
echo $approvedby;
echo $vendorid1;
//update_approved($indexnum, $approvedby, $vendorid1);
//header('Location: index.php');
//exit();
}
else if(empty($errors) === false)
{
echo output_errors($errors);
}
}
}
?>
<form name="approveform" method="POST" action="">
<?php echo "<input type=\"hidden\" name=\"hidden1\" value=\"$id\">" ?>
Index Number*: <input type="text" name="IndexNum">
<input type="submit" value="Approve" action="">
</form>
<?php }
}
感谢大家对此进行调查。我从以前的 POST 中获得了 $id 值。我在代码的其他地方使用它没有问题。
非常感谢大家!