www.webdeveloper.com
Results 1 to 4 of 4

Thread: Whats Wrong with my Form Processor?

  1. #1
    Join Date
    Sep 2010
    Posts
    2

    Whats Wrong with my Form Processor?

    Hey Guys,

    I have removed the emails I normally have in the functions but what is wrong with this code? I would really rather not have the elseif statement, as there are about 4 different types of things I need to have which Change the Result of the email my Customer Receives.

    Code:
    <?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
    
    //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!";
    }
    
    switch ($type) {
        case "Graphic Design":
            Design();
            break;
        case "Websites":
            WebDesign();
            break;
        case "Photography":
            Photography();
            break;
    }
    
      
    ?>

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    724
    Since I don't see any error messages and since you didn't give us an indication of "what is wrong", I can only say that this is absolutely perfect code!

    Give us a hint as to what is supposedly wrong and perhaps someone can help you.....

    I do have to wonder how you expect an array to be emailed to you.

  3. #3
    Join Date
    Sep 2010
    Posts
    2
    The Case Was Working!

    Earlier version showed it was collecting the Variables Correctly haven't adjusted that. before the case was pretty much just a conditional if statement & one email template.

    Only thing its not doing is actually sending the Mail, it does Echo out the Right Message though.

  4. #4
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    724
    Code:
    <?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?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles