我似乎无法让我的代码工作?

时间:2015-07-15 11:32:41

标签: php html twitter-bootstrap

我希望能够向两个不同的电子邮件地址发送电子邮件,但电子邮件发送到的地址将取决于在位置列表中选择的位置。目前我正收到第一封电子邮件至info@me.com,并且只发送了其他电子邮件的列标题,我没有收到任何内容。请有人帮忙。

<?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>     

0 个答案:

没有答案