从html表单

时间:2017-04-28 15:34:14

标签: php html

我写了以下代码,用于从我的网站向我的电子邮件地址发送电子邮件。

但它不起作用。

我在网站的联系页面中使用了以下HTML表单。

<?php

if(isset($_POST['submit'])) {
        $to ="amishaharali@gmail.com";
        $subject = "E-mail from Ushar Alo Contact Person";
        $txt = $_POST['comment']." -by :".$_POST['mail'];


$headers = "From: msalipbl@gmail.com";

        if(mail($to,$subject,$txt,$headers)){
                echo "Successfully sent!";
                }else{
                echo " Sorry! a problem to send the E-mail!";
                }

}else{


?>
        <hr/>

        <h3>Send e-mail to the Administrator :</h3>

        <form action="http://usharalo.eu.pn/contact.php" method="post">
        Name:<br>
        <input type="text" name="name"><br>
        E-mail:<br>
        <input type="text" name="mail"><br>
        Comment:<br>
        <input type="text" name="comment" size="50"><br><br>
        <input type="submit" name ="submit" value="Send">
        <input type="reset" name="reset" value="Reset">
        </form>

<?php } ?>

0 个答案:

没有答案