bravo14 Posted January 10, 2013 Share Posted January 10, 2013 I am passing a radio button from a form $_POST['council'] if the radio button is selected I want the value set to 1 if not then it is set to 0, this will then dictate the charge that is set. The code I am using at the moment is $council=0; if(isset($_POST['council'])){ $council=1; } if($council=1){ $charge='10'; } else{ $charge='2.50'; } However at the moment if the radio button is not selected the charge is still set to 10, if it is selected the charge is set to 10, what am I doing wrong? Quote Link to comment Share on other sites More sharing options...
premiso Posted January 10, 2013 Share Posted January 10, 2013 (edited) You are using an assignment operator in your if ( = ) and not the conditional one ( == ). Change that and it should work properly. $council=0; if(isset($_POST['council'])){ $council=1; } if($council == 1){ $charge='10'; } else{ $charge='2.50'; } Edited January 10, 2013 by premiso Quote Link to comment Share on other sites More sharing options...
Love2c0de Posted January 10, 2013 Share Posted January 10, 2013 You are using the assignment operator '=' instead of the comparison operator '==' in the second if statement, therefore the if statement interprets the 1 as a TRUE value and will always execute the if statement. Just change the second if to ==. Kind regards, L2c Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.