Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Utter newbie & stressing redirect based on form value

the mail() function

Moderators: macek, egami, gesf

Utter newbie & stressing redirect based on form value

Postby LegoBeast » Fri Dec 23, 2011 5:48 am

Dear All

I have made a successful html form with mail.php "thing" my only problem is I want to be able to redirect to 2 different thank you pages based on a value entered in the html form.

Value field is "Type1" and people can enter either burger, farm or shop

Thank you.....

this is my mail.php

<?php
$name = $_POST['name'];
$bedrijfsnaam = $_POST['bedrijfsnaam'];
$adres = $_POST['adres'];
$plaats = $_POST['plaats'];
$postcode = $_POST['postcode'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$socialemedia = $_POST['socialemedia'];
$website = $_POST['website'];
$Type1 = $_POST['Type1'];
$type = $_POST['type'];
$productendiensten = $_POST['productendiensten'];
$productendiensten_anders = $_POST['productendiensten_anders'];
$vragen = $_POST['vragen'];
$formcontent=" Bevestiging van: $name, deze persoon is $Type1 \n Bedrijfsnaam: $bedrijfsnaam \n Adres: $adres $postcode $plaats \n Gebruiker van Sociale Media: $socialemedia \n Producten en Diensten: $productendiensten \n Anders: $productendiensten_anders \n Vragen en/off Opmerkingen: $vragen";
$recipient = "me@myemail.com";
$subject = "Contact";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
if (isset ($Type1['Burger']))
{
header("Location: burgerthanks.htm"); //the user will be sent to this page
}
if (isset ($Type1['Farm'])) {
header('Location: option2.htm');
} else
header('Location: thanks1.htm');
?>
LegoBeast
New php-forum User
New php-forum User
 
Posts: 1
Joined: Fri Dec 23, 2011 5:42 am

Re: Utter newbie & stressing redirect based on form value

Postby egami » Fri Dec 23, 2011 7:52 am

Are you sure that $Type1 is an array?


it would seem to me that it's just a variable, so you're IF statement is off.

You would need to re-write it to something like..

Code: Select all
if (isset($Type1)) { 
 switch (
strtolower($Type1)) { 
  case 
"farm":
   
$redirect "farm.php";
   break;
  case 
"house":
   
$redirect "house.php";
   break;
  case 
"apartment":
    
$redirect "apartment.php";
    break;
  default:
    
$redirect "default.php";
    break;
  }
} else { 
  
$redirect "cantfindit.php";
}

header("Location: $redirect");
 
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.