用php发送输入

时间:2017-07-24 17:24:17

标签: php html forms post

我知道,这个话题并不新鲜,但我遇到了问题,无法继续下去。如果有人可以帮助我,我会很高兴。

我的form上有website,现在,我想将输入发送到我的电子邮件地址。但是当我点击submit-button时,我没有收到任何电子邮件,而是打开了我的php代码。怎么了?

这是我的HTML代码:

 <form action="sendMail.php" method="post" name="form">
    <table border="0" cellspacing="0" cellpadding="2">
        </tr>
        <tr>
          <td>Vorname:</td>
          <td>
            <input maxlength="50" name="vorname" size="45" type="text" />
          </td>
        </tr>
        <tr>
          <td>Email:</td>
          <td>
            <input name="email" size="45" type="text" />
          </td>
        </tr>
        <tr>
          <td>Mitteilung:</td>
          <td><textarea cols="30" rows="5" name="msg" placeholder="Ihre Mitteilung"></textarea></td>
        </tr>
        <tr></tr>
        <tr>
          <td>
            <input type="submit" name="submit" value="Abschicken" />
          </td>
        </tr>
      </tbody>
    </table>
</form>

那是我的PHP代码:

    <?php
        if(isset($_POST['submit'])){
            $name=$_POST['name'];
            $vorname=$_POST['vorname'];
            $email=$_POST['email'];
            $msg=$_POST['msg'];

            $to='x.y@zzz.com';
            $subject='Form Submission';
            $message="Name :".$name."\n"."Vorname :".$vorname."\n"."Wrote the following :"."\n\n".$msg;
            $headers="From: ".$email;

            if(mail($to, $subject, $message, $headers)){
                echo "<h1>Sent Successfully! Thank you"." ".$name.", We will contact you shortly!</h1>";
            }
            else{
                echo "Something went wrong!";
            }
        }
    ?>

当我点击submit时,我明白了:

Thats what happen in my browser

非常感谢你的帮助!

0 个答案:

没有答案