我对编码非常陌生,并尝试使用此处的代码设置联系表单:http://codepen.io/rexkirby/pen/Fdnlz
我现在需要使其功能化,但对PHP有0知识。我已经尝试了很多不同的PHP代码,但我甚至不知道如何正确地将html文件链接到.php文件。我的代码在下面,如果有人能告诉我如何链接文件我会非常感激!
HTML:
<div id="form-main">
<div id="form-div">
<form class="form" id="form1" action="mail.php" method="post">
<p class="name">
<input name="name" type="text" class="validate[required,custom[onlyLetter],length[0,100]] feedback-input" placeholder="Name" id="name" />
</p>
<p class="email">
<input name="email" type="text" class="validate[required,custom[email]] feedback-input" id="email" placeholder="Email" />
</p>
<p class="text">
<textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="Comment"></textarea>
</p>
<div class="submit">
<input type="submit" value="SEND" id="button-blue"/>
<div class="ease"></div>
</div>
</form>
</div>
腓
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$from = $_REQUEST['author'] ;
$to = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['msg'] ;
mail($to, $subject, $message, "From:" . $from);
// the mail was sent
echo "Thank you for using our mail form";
}
else {
//if "email" is not filled out, display the form
//just close php and copy the code for your form
?>
答案 0 :(得分:1)
谢谢!我终于对问题进行了排序,结果发现GitHub不支持php,这是我托管它的地方
答案 1 :(得分:0)
首先创建一个名为mail.php的文件,并将其放在与html / css文件相同的目录中。
mail.php文件负责处理您的表单,然后将其发送到您希望的任何位置。保存这些文件,只需在WAMP / LAMP / XAMP等网络服务器或实时服务器(如果有的话)上进行测试。