Utter newbie & stressing redirect based on form value

the mail() function

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Fri Dec 23, 2011 5:42 am

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

$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');

User avatar
php-forum GURU
php-forum GURU
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

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)) { 
$redirect "farm.php";
$redirect "house.php";
$redirect "apartment.php";
$redirect "default.php";
} else { 
$redirect "cantfindit.php";

header("Location: $redirect");

Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 3 guests