0

I want to be able to send email to two different emails address but the address which the email is sent to will depend on the location selected on the location list. At the moment I am getting emails for my first info@me.com and it only sends the the column headers as for the other email, I am not getting anything. Please could someone help.

<?php
    header('Content-type: application/json');
    $status = array(
        'type'=>'success',
        'message'=>'Thank you for contact us. As early as possible  we will contact you '
    );

    $emals = [    
        $name = @trim(stripslashes($_POST['name'])), 
        $title = @trim(stripslashes($_POST['title'])), 
        $email = @trim(stripslashes($_POST['email'])), 
        $number = @trim(stripslashes($_POST['number'])), 
        $message = @trim(stripslashes($_POST['message'])), 
        $location = @trim(stripslashes($_POST['location']))
    ];

    $email_from = $email;

    switch ($location) {
        case 'United Kingdom':
            $email_to = "info@me.com";
            break;
        case 'Ireland':
            $email_to = "email@me.com";
            break;
        default:
            $email_to = "iinfo@me.com";
            break;
    }

    $body = 'Title: '. $title . "\n\n" .'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Number: ' . $number . "\n\n" . 'Message: ' . $message . "\n\n" . 'Location: '. $location;

    $success = @mail($email_to, $number, $body, 'From: <'.$email_from.'>');

    echo json_encode($status);
    die;
    ?>
<html>

<head>  

</head>
<body>

            <div class="row contact-wrap"> 
                <div class="status alert alert-success" style="display: none"></div>
                <form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendenquiry.php">
                    <div class="col-sm-10 col-sm-offset-1">
                    <br/> 
                    <h2>Call one of our experts on</h2> <br/>

                    <h2> <label> <a href="tel://033 0335 1277"><span class="glyphicon glyphicon-phone-alt"></span>&nbsp 033 0335 1277</a> </label> <p/></h2>

                        Simply complete the form below and one of our experts will get back to you.<p/> 
                        <div class="form-group">
                        Location *
                        <select name = "location"  class="form-control">
                        <option value="United Kingdom">United Kingdom</option>
                        <option value="Ireland">Ireland</option>
                        </select>
                        </div>
                        <div class="form-group">
                        Full Name*
                        <input name = "name" type="text" class="form-control" required="required">
                         </div>
                        Email-Address *
                        <div class="form-group">
                           <input type="email" class="form-control" required="required">
                        </div>
                        Telephone Number*
                        <div class="form-group">
                           <input type="number" class="form-control" required="required">
                        </div>


                        <div class="form-group">

                            <textarea name="message"= placeholder="Basic description of your enquiry" id="message" required="required" class="form-control" rows="8"></textarea>
                        </div>                        
                        <div class="form-group">
                            <button type="submit" name="submit" class="btn btn-primary btn-lg" required="required">Submit Message</button>
                        </div>
                 </div>
                </form> 
            </div><!--/.row-->


</body>


</html>     
Siguza
  • 21,155
  • 6
  • 52
  • 89
  • 2
    first remove `@` from your script... and turn on error reporting to actually get an error or warning that may guide you to a fix http://stackoverflow.com/questions/1032161/what-is-the-use-of-symbol-in-php – Jorge Y. C. Rodriguez Jul 15 '15 at 11:35
  • Try using variables taken from the form, rather than plain text for the locations. – Lansana Camara Jul 15 '15 at 11:37
  • Where do you define $status? – panepeter Jul 15 '15 at 11:48
  • Sorry I'm new on here, I have define it at the top of my php file, and that works fine. header('Content-type: application/json'); $status = array( 'type'=>'success', 'message'=>'Thank you for contact us. As early as possible we will contact you ' ); – John smith Jul 15 '15 at 11:57
  • `$email_to = "iinfo@me.com";` Is this really the default? Should it be `info@me.com`? – Anthony Rutledge Jul 19 '15 at 15:15

0 Answers0