我的网络表单未链接到我的电子邮件

时间:2016-05-26 22:36:37

标签: php html syntax

我正在尝试为网站创建一个网络表单,但是当我点击发送时,该页面链接到.php文件。请告诉我我做错了什么。

.html和.php代码分别如下所示:

<form action="email.php" method="post">
    <input class="input-text animated wow flipInY delay-02s" type="text" name="name" value="Your Name *" onFocus="if(this.value==this.defaultValue)this.value='';" onBlur="if(this.value=='')this.value=this.defaultValue;">
    <input class="input-text animated wow flipInY delay-04s" type="text" name="email" value="Your E-mail *" onFocus="if(this.value==this.defaultValue)this.value='';" onBlur="if(this.value=='')this.value=this.defaultValue;">
    <textarea class="input-text text-area animated wow flipInY delay-06s" name"description" cols="0" rows="0" onFocus="if(this.value==this.defaultValue)this.value='';" onBlur="if(this.value=='')this.value=this.defaultValue;">Describe your facilities and what you’re looking for. *</textarea>
    <input class="input-btn animated wow flipInY delay-08s" type="submit" value="send message">
</form>

<?php

$name = $_POST['name'];
$email = $_POST['email'];
$description = $_POST['description'];
$to = "Email Address";
$subject = "Facility and Other Specifications";

mail($to, $subject, $description "From: " . $name);
echo "Your message has been sent.";

?>

此外,我不确定如何将PHP与.php和.html文件一起使用,或者我使用的操作系统(Snow Leopard)是否已经附带它。

我对这一切都有点新意,我们将非常感谢任何信息。

2 个答案:

答案 0 :(得分:3)

如果您的意思是我认为您的意思,那么它就链接到您的PHP文件的文字代码。从那以后,我可以告诉你,你可能没有安装PHP。因此,您需要install it

答案 1 :(得分:1)

确保您的php代码在单独的文档中(email.php)。

额外:更改

mail ($to, $subject, $description "From: " . $name);
echo "Your message has been sent.";

    $success = mail($to, $subject, $description "From: " . $name)
    if($success){
        echo "Your message has been sent.";
    }else{
        echo "Mail failure";
    }

现在你的代码即使在失败时也会说成功。 mail函数在成功时返回true,因此您只需检查变量以查看它是否有效