简体   繁体   English

如果提交表单php的语句问题

[英]If statment issue with submit form php

I have a site in which an Admin User looks at rows of invoices which have been submitted by users, when they click on an 'Approve Invoice' button from one of these rows it will take them on the page below. 我有一个网站,其中管理员用户查看用户提交的发票行,当他们点击其中一行中的“批准发票”按钮时,它将在下面的页面上显示。

Once the Admin User approves this invoice, they hit the 'yes' radio button and submit at the bottom of the page which enters the value 'AUDITED' under the 'npc_active' column in that row. 管理员用户批准此发票后,他们点击“是”单选按钮并在页面底部提交,该行在该行的“npc_active”列下输入值“AUDITED”。 It then multiplies the quantity and points and inserts the total onto a new row in 'tally_points' (along with their user id and sales id). 然后,它将数量和点数相乘,并将总数插入“tally_points”中的新行(以及它们的用户ID和销售ID)。 This is all working fine, but... 这一切都很好,但......

What I am trying to do, however, is make a condition in which once the sale is audited, that it can't be re-audited. 然而,我想要做的是制定一个条件,一旦审计销售,就不能重新审计。 ie the 'This invoice has been audited' print should show once the submission has taken place, but it isn't working. 即,“此发票已经过审核”打印应在提交完成后显示,但不起作用。

I'm close but can't seem to figure out what the problem is. 我很接近,但似乎无法弄清问题是什么。 The code in which I think I am having the problem is below, the full page code is at the bottom of this post. 我认为我遇到问题的代码如下,整页代码位于本文的底部。

$str ='<form method="post" action="audit_invoice.php">
    <font style="font-size:11px;">
    <em>Is this invoice approved?<br />';
if($approved == "AUDITED") {
    $str .='Please select carefully as this action cannot be undone.</em>
    <em>Yes:</em><input type="radio" value="AUDITED" name="npc_active">  <em>No:</em>
        <input type="radio" value=" " name="npc_active"> 
        <input type="submit" name="submit" value="Submit" />
        <input type="hidden" name="submitted" value="TRUE" />
    <input type="hidden" name="id" value="' . $id . '" />
        </font>
        </form></tr>';
}
else {
    $str .='This invoice has been audited'; 
}
echo $str;

If I put the '==' before "AUDITED" it will show up with the echo 'The invoice has been audited' in each instance, if I put '=' in front of "AUDITED" it will show the yes button and submit button in each instance. 如果我在“AUDITED”之前加上'==',它会在每个实例中显示echo'发票已被审核',如果我在'AUDITED'前面加上'=',它将显示yes按钮并提交每个实例中的按钮。

@AdamMC the = operator is only used when assigning data. @AdamMC =运算符仅在分配数据时使用。

You are comparing a data, therefore you are correct when using == 您正在比较数据,因此在使用==时您是正确的

if($approved == "AUDITED") 

I would like to request what exactly your $approve variable contains. 我想请求你的$ approve变量包含什么。 As of right now I can only make an assumption that this code implies 截至目前,我只能假设此代码暗示

if invoice is approved it would equal audited which then would trigger it to echo "this invoice has been audited" 如果发票被批准,它将等于审计,然后将触发它回应“此发票已经过审计”

To stackoverflow users: please do not downvote, I cannot comment because my reputation does not permit it. stackoverflow用户:请不要downvote,我不能发表评论,因为我的声誉不允许。 Just trying to help 只是想帮忙

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM