Jump to content

[SOLVED] Sendmail redirect based on form content


theredking

Recommended Posts

Hi, I'm still very new to this, but trying to learn quickly...

 

I want to use sendmail to send me form data, and then redirect to different URLs (in this specific case different Paypal buy now buttons) with the click of one button, based on which radio button is selected.

 

I have the form set up and working, but I can't work out what I need to edit to change the way the form is handled based on which 1 of 3 radio buttons is selected... I still want to receive the contents of the form (Name, Address, etc.) to the specified email address, but I want it to appear to seamlessly move to the correct page once the "submit" button is clicked.

 

I've tried searching to teach myself how to do this, but I've hit a bit of a brick wall. Any help would be greatly appreciated.

 

Thank you in anticipation...

 

I assume it is the header section of this snippet of the sendmail code that I will need to be altering?

 

<?php   
   
  }
  else {

  mail( "me@myemailaddress.com", "Subject of email",
    "$name\n$address\n$city, $state, $zip\nPhone Number: $phone\nCell Phone: $cell\n$email\n\nRadio Button Value: $radio\n\nMessage\n\n$line1\n$line2", 
"From: $name <$email>" );
  
  
  header( "Location: http://www.mywebsite.com/thank-you.html" );
}

?>

Link to comment
Share on other sites

Sorry, I'm sure this is a simple error I am making, or just a blatant misunderstanding, but I have now changed my code to look like this... and it is telling me I am getting a parse error because of an unexpected "}"

 

<?php   
   
  }
  else {

  mail( "me@myemailaddress.com", "Star of Tomorrow purchase",
    "$name\n$address\n$city, $state, $zip\nPhone Number: $phone\nCell Phone: $cell\n$email\n\nRadio Button Value: $radio\n\nMessage\n\n$line1\n$line2", 
"From: $name <$email>" );
  
}

$radio = $_GET['radio'];
if ($radio == "value1")
$redir = "http://www.mysite.com/1.html";
}elseif($radio == "value2"){
$redir = "http://www.mysite.com/2.html";
}elseif($radio == "value3"){
$redir = "http://www.mysite.com/3.html";
}
header("Location:$redir");
?>

 

The unexpected "}" character appears on this line: }elseif($radio == "value2"){

 

Thanks for the prompt reply!

Link to comment
Share on other sites

Ah ha!

 

I think I've stumbled across the solution by troubleshooting....

 

<?php   
   
  }
  else {

  mail( "me@myemail.com", "Email Subject Goes Here",
    "$name\n$address\n$city, $state, $zip\nPhone Number: $phone\nCell Phone: $cell\n$email\n\nRadio Button Value: $radio\n\nMessage...\n\n$line1\n$line2", 
"From: $name <$email>" );

}	

if ($radio == "4")
$redir = "http://www.mysite.com/1.html";
elseif($radio == "6"){
$redir = "http://www.mysite.com/2.html";
}
header("Location:$redir");
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.