I have a form that is sending in sizes of things, and I need to see what the strings are equal to so that I can set the price accordingly. When i try to do this, it says that they are not equal, and i get no prices. This is the code i’m using:
if ($_POST['sizes'] == 'Small ($30)'){$total = '30';} if ($_POST['sizes'] == 'Medium ($40)'){$total = '40';} if ($_POST['sizes'] == 'Large ($50)'){$total = '50';} else {$total = $_POST['price'];}
What am i doing wrong here? I can echo $_POST[‘sizes’] and it gives me exactly one of those things.
What Paul Dixon said is correct. Might I also recommend using a switch statement instead of that clunky chunk of if statements (which actually has a logic bug in it, I might add –
$totalwill always equal$_POST['price']when not'Large ($50)')