AdRock Posted August 25, 2007 Share Posted August 25, 2007 I have a form with a radio button and depending on the value of it's 'yes' or 'no' I want to perform 2 differnet SQL queries. How do i create the IF statement? Here is the form radio buttons <input style="border:none" type="radio" value="yes" checked name="newsletter">Opt-in <input style="border:none" type="radio" value="no" name="newsletter">Opt-out Would I do something like if ($_POST['newsletter'] == 'yes' { //do sql } else { //do sql } Quote Link to comment https://forums.phpfreaks.com/topic/66622-solved-how-to-perform-if-stement-depending-on-value-of-form-radio-button/ Share on other sites More sharing options...
Trium918 Posted August 25, 2007 Share Posted August 25, 2007 Or something like the following. <?php $newsletter= $_POST['newsletter']; switch($newsletter) { case radio1: $sql = " "; break; case radio2: $sql = " "; break; default: echo "There is a problem in your script"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/66622-solved-how-to-perform-if-stement-depending-on-value-of-form-radio-button/#findComment-333794 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.