irnbru1984 Posted September 16, 2009 Share Posted September 16, 2009 I have inherited a website with a contact form which works well enough but I have been asked to add a conditional to the form which has 2 different outcomes. I have this as the code for the drop down options to allow the user to choose if they want the newsletter or not <tr><td class="form_text">Would you like to receive our Newsletter:</td> <td valign="top"><select name="Newsletter"> <option value="Yes" selected>Yes Please</option> <option value="No">No Thank You</option> </select></td> </tr> I have tried creating an IF/ELSE statement such that if they choose yes that an email will be sent to a second person away from the original mail. Can anyone help me to understand why this isnt working. if($fields{"Newsletter"} == 'Yes') { mail("[email protected]", $subject, $body, $headers);} else { header('Location:http://www.ntdfreelance.co.uk/sorry.php');} I dont know if the text inside the '' after the == function needs to be the option value or the text inside box n the site. Any help would be very much appreciated. Thanks Link to comment https://forums.phpfreaks.com/topic/174436-ifelse-statement-in-mailing-function/ Share on other sites More sharing options...
Bricktop Posted September 16, 2009 Share Posted September 16, 2009 Hi irnbru1984, Are you receiving an error message or is the sorry.php page being displayed everytime regardless of the option you choose in the drop-down box? Also, try echoing out the value of $fields{"Newsletter"} to see what it contains. Above your if statement just add: echo $fields{"Newsletter"}; Then submit your form and you will see the output from the echo statement at the top of the page. Hope this helps. Link to comment https://forums.phpfreaks.com/topic/174436-ifelse-statement-in-mailing-function/#findComment-919400 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.