PHP if/else can't detect option value (please help)

Hello DevShed Forums,

I have been spending countless hours tackling this bit of code but I have unfortunately failed many times. The idea seems to be simple, and I could've sworn I've done this before. Something has to be wrong... I decided I would get some help and hopefully someone here would be able to find out why this code is not working.

I want to create a PHP if/else statement that will determine the value of $postage. I have a simple HTML select option form and I was using PHP to figure out what selection the user has made upon clicking the submit button.

Why canít I use certain words like "drop" as part of my Security Question answers?
There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

the syntax and the content of the conditions makes no sense. The || operator is the logical "or". You use it to combine two boolean expressions:

PHP Code:

$age >= 21 || $bribe >= 100

It seems you have tried to literally translate human language into code ("The delivery is this or that"). This doesn't work.

The conditions themselves also make no sense. The form submits the values of the options (i. e. "0" or "1"), not the labels.

Hello, thank you for replying. A couple clarifications I would like to make... I originally tried if($delivery == "0") {} but it would not run the function. However, the only time I ever got it to work was when I typed if($delivery == "0" || "FREE - Standard (2-3 business days)") {}

I don't know why and I know that it would've made more sense to type it this way: if($delivery == "0" || $delivery == "FREE - Standard (2-3 business days)" {}

I've also tried it where it was just | $delivery == "FREE - Standard (2-3 business days)" {} and that didn't work either.

For some reason I am not able to retrieve the selected value from the dropdown menu. Why is that? Is there anything else wrong with the code?

Why canít I use certain words like "drop" as part of my Security Question answers?
There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

those echoes are just to test which "branch" is executed so you can test/debug

or You can do it a bit more sophisticated, create a function something like

function testing ( $message, $flag){
echo $message;
}

then instead of echoing.

do testing ("message", $flag);

then set flag somewhere at the top, this way you dont constantly have to comment/uncomment debug code and instead set it using flag, which can come from a session OR $_GET/$_POST variable

Oh I'm sorry I totally missed your message! I really appreciate you taking your time and reading my problem. I am at church at the moment but as soon as ill get out ill try out your suggestion and let you know what results I get

Are you sure that is what I need to do? It doesn't really make sense to me... Perhaps I need to show you more of my html code. The only part of the form is the drop down menu. And the submit button is a paypal ipn image input.

yes because the first time i see this page, i havent made a decision yet on what postage i will choose as your customer so how can you run that code? that code will only get run & you can choose to show the form AGAIN after i choose the correct postage.

aah I see. In this case the easiest solution would be (and i assume you will update a hidden form field when i choose a postage option, right?) to use jquery/ajax to change the value of the hidden field relating to the postage when/if i change the value of select.

You are sending the information to PayPal, have you validated/checked that PayPal does send back the information? using POST or GET?
(have no experience with PayPal and its "API")

I'm sending information(variables) to PayPal. And yes I know that you can because all my other variables are working. But for some reason this form cannot recognize the Value for each <option></option> tag.