Jump to content

Problem With If Stmt From A Select?


Recommended Posts

Hello I am totally new to PHP, but I thought the following code would work for my form. It is executing the code to send the email even though I thought it was only to process if the reason is a "transfer". Could someone please help me? My site is www.dcyoungmarines.com and here's the PHP code I'm executing.Thank you! ChrisHere's my select statement in the form: <td><select name="reason"> <option>Recruit Interest List</option> <option>Young Marine Transfer</option> <option>Volunteer Interest</option> <option>Contact Me</option> </select></td>Here's the PHP code: <?php // Grab the form vars $childname = (isset($_POST['childname'])) ? $_POST['childname'] : '' ; $age = (isset($_POST['age'])) ? $_POST['age'] : '' ; $###### = (isset($_POST['######'])) ? $_POST['######'] : '' ; $parentname = (isset($_POST['parentname'])) ? $_POST['parentname'] : '' ; $email = (isset($_POST['email'])) ? $_POST['email'] : '' ; $hphone = (isset($_POST['hphone'])) ? $_POST['hphone'] : '' ; $cphone = (isset($_POST['cphone'])) ? $_POST['cphone'] : '' ; $reason = (isset($_POST['reason'])) ? $_POST['reason'] : '' ; $comments = (isset($_POST['comments'])) ? $_POST['comments'] : '' ; // send email to dcyoungmarines mail("dcyoungmarines@q.com","Interest Form Submission", "Child Name: $childname\n Age: $age\n ######: $######\n\n Parent/Guardian Name(s): $parentname\n Email Address: $email\n Home Phone: $hphone\n Cell Phone: $cphone\n Interest Reason: $reason\n\n Comments:\n $comments");// send a transfer request to user if requested if ($reason = "Young Marine Transfer") { $to = "$parentname<$email>"; $subject = "Young Marine Transfer Request"; $msg = "Dear " . $parentname . "\n\n" . "You have requested information regarding your Young Marine's possible " . "transfer to the Douglas County Young Marines. On our forms page you will find " . "a Young Marine Transfer Request form. Please complete the form and email it to us " . "at dcyoungmarines.com. We will contact you as well as the Young Marine's current " . "commanding officer in order to insure that the Young Marine is in good standing with ". "his unit.\n\n" . "We appreciate you interest in the our unit and we will be contacting you as soon as " . "possible.\n\n" . "Chris Proctor\n" . "Commanding Officer"; // send email to parents of young marine if( mail($to,$subject, $msg)) { echo "<p>The transfer request has been sent. You will soon be receiving an email with transfer request instructions. Please follow the instructions to help us expedite the transfer. Thank you.</p>"; } else{ die( "An error occurred while attempting to send the transfer request."); } }?>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...