0

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;
$bedrijfsnaam = $_POST;
$adres = $_POST;
$plaats = $_POST;
$postcode = $_POST;
$email = $_POST;
$phone = $_POST;
$socialemedia = $_POST;
$website = $_POST;
$Type1 = $_POST;
$type = $_POST;
$productendiensten = $_POST;
$productendiensten_anders = $_POST;
$vragen = $_POST;
$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))
{
header("Location: burgerthanks.htm"); //the user will be sent to this page
}
if (isset ($Type1)) {
header('Location: option2.htm');
} else
header('Location: thanks1.htm');
?>

2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by urtrivedi
0

you must exit after using header function

<?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
exit;
}
if (isset ($Type1['Farm'])) {
header('Location: option2.htm');
exit;
} else
header('Location: thanks1.htm');
exit;
?>
0

I tried this but it keep defaulting to the first header burgerthanks.htm regardless of people enter ;(. It seems it does not want to go through with the other steps...

0

isset check whether the variable exists or not , it returns true even if the value is blank. so you may check accordingly like

if (isset ($Type1['Burger']) && trim($Type1['Burger'])!='' ) {
{
header("Location: burgerthanks.htm"); //the user will be sent to this page
exit;
}
if (isset ($Type1['Farm']) && trim($Type1['Farm'])!='' ) {
header('Location: option2.htm');
exit;
} else
header('Location: thanks1.htm');
exit;
0

hi urtrivedi nope still not working... SORRY!!! I now if I copy and paste the full lot also get an error message

<?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: $Twitter, $Facebook, $LinkedIn, $Hyves \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']) && trim($Type1['Burger'])!='' ) {
{
header("Location: burgerthanks.htm"); //the user will be sent to this page
exit;
}
if (isset ($Type1['Farm']) && trim($Type1['Farm'])!='' ) {
header('Location: option2.htm');
exit;
} else
header('Location: thanks1.htm');
exit;
?>

on the last line...

the html form with the value bit
<form action="mail.php" method="POST" onsubmit="MM_validateForm('name','','R','email','','RisEmail','phone','','NisNum');return document.MM_returnValue">
<table width="500" border="0" cellpadding="10" cellspacing="0">
<tr>
<td width="161">Ik ben een ....</td>
<td width="299"><select name="Type1" size="1">
<option value="Burger">Burger</option>
<option value="Farm">Farm</option>
<option value="Sausage">Sausage</option>
</select></td>

0
if (trim($Type1)=='Burger' ) {
{
header("Location: burgerthanks.htm"); //the user will be sent to this page
exit;
}
if (trim($Type1)=='Farm']) {
header('Location: option2.htm');
exit;
} else
header('Location: thanks1.htm');
exit;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.