<?php
// COLLECT POST VARIABLES
$name = $_POST['name']; // required
$email = $_POST['email']; // required
$mobile = $_POST['mobile']; // required
$type = $_POST['type']; // not required
$budget = $_POST['budget']; // required
$deadline = $_POST['deadline']; // required
$brief = $_POST['brief']; // required
switch ($type)
{
case "Graphic Design":
Design();
break;
case "Websites":
WebDesign();
break;
case "Photography":
Photography();
break;
}
//******************************************
// Functions follow here
//******************************************
//EMAIL TEMPLATES
function WebDesign()
{
$to = "*****";
$subject = "WEB DESIGN EMAIL";
$message=array("Name: \n $name \n","Email: \n $email \n","Mobile: \n $mobile \n","Project Type: \n $type \n","Project Budget: \n $budget \n","Project Deadline: \n $deadline \n","Project Brief: \n $brief \n");
$from = "*******";
$headers = "From:" . $from;
@mail($to,$subject,$message,$headers);
echo "Your Web Design Questionnaire Email has been Sent!";
}
//**************************
function Design()
{
$to = "****";
$subject = "WEB DESIGN EMAIL";
$message=array("Name: \n $name \n","Email: \n $email \n","Mobile: \n $mobile \n","Project Type: \n $type \n","Project Budget: \n $budget \n","Project Deadline: \n $deadline \n","Project Brief: \n $brief \n");
$from = "*****";
$headers = "From:" . $from;
@mail($to,$subject,$message,$headers);
echo "Your Graphic Design Questionnaire Email has been Sent!";
}
//***************************
function Photography()
{
$to = "****";
$subject = "WEB DESIGN EMAIL";
$message=array("Name: \n $name \n","Email: \n $email \n","Mobile: \n $mobile \n","Project Type: \n $type \n","Project Budget: \n $budget \n","Project Deadline: \n $deadline \n","Project Brief: \n $brief \n");
$from = "****";
$headers = "From:" . $from;
@mail($to,$subject,$message,$headers);
echo "Your Photography Questionnaire Email has been Sent!";
}
?>
Re-arranging the code for readability's sake I don't see anything wrong except that you won't be getting very good output since your vars aren't defined in each of the functions.
When you say the switch is not working why don't you echo the value of $type to be sure it is in the list of cases?