我的表单提交无效

时间:2017-08-22 19:37:06

标签: php email post

HTML代码

                        <h3>online consultation</h3>

                        <h5>We have provided contact information down below. You can contact us either by mobile, via email or via contact form. We will at once contact you to discuss your problems! If you have special requirments a consultation can be decided.</h5>


                        </div>


                                  <div class="col-md-7 col-lg-offset-3 contact-grid-right">                     

                             <form  method="post" action="mail.php">

                               <input type="text" placeholder="Your Name" name="name" id="name" required="required">

                               <input type="text" placeholder="Email" name="Email" id="Email" required="required">

                                   <input type="text" placeholder="Contact No" name="contact" id="contact" required="required">

                              <input type="text" placeholder="Subject"  name="subject" id="subject" required="required">

                              <textarea rows="2" cols="70" type="text" placeholder="MESSAGE"  name="message" id="message" required="required">

                                                           </textarea>


                          <button type="submit" class="slide-btn"> Send your message <i class="fa fa-paper-plane" aria-hidden="true"></i> <br></button>                                 


                         </form>


                         </div>

PHP脚本

<?php

$n=$_POST['name'];
$mail=$_POST['email'];
$ph=$_POST['contact'];
$ln=$_POST['subject'];
$msg=$_POST['message'];
$to="email@yahoo.com";
$sub="message";

$body="
<html>
    <body>
        <p><b></b></p><h4></h4>
        <table border='0'>
            <tr>
                <b>Name : </b> $n <br><br>
                <b>Email : </b> $mail <br><br>
                <b>Contact :</b> $ph  <br><br>
                <b>Subject :</b> $ln <br><br>
                <hr>
                <b>Contact Form Message:</b> <br><br>$msg 
            </tr>
        </table>
    </body>
</html>";


$headers = "MIME-Version: 1.0". "\r\n";

$headers .= "Content-type:text/html;charset=UTF-8". "\r\n";

$headers .= 'From:'.$mail . "\r\n";

//$headers .= 'Cc: email@yahoo.com.au'; "\r\n";

//$headers .= 'Bcc: '; "\r\n";

mail($to,$sub,$body,$headers);

//echo "<script>alert('Message Send Sucessfully')</script>";

echo "<script>window.location.href='index.html'</script>";



?>

2 个答案:

答案 0 :(得分:0)

此处解决方案更改了$ mail = $ _ POST ['email'];在您的PHP脚本中$ mail = $ _ POST ['电子邮件'];

答案 1 :(得分:0)

为了保持代码标准,请将电子邮件html输入替换为:

function HomeController(AuthService, $state) {
    let ctrl = this;
}