简体   繁体   中英

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. 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). 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.

@AdamMC the = operator is only used when assigning data.

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. 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. Just trying to help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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