简体   繁体   English

html/css 联系表单的 PHP 帮助

[英]Php help for html/css contact form

I am very new to coding and am trying to set up a contact form using code from here: http://codepen.io/rexkirby/pen/Fdnlz我对编码很陌生,正在尝试使用以下代码设置联系表格: http : //codepen.io/rexkirby/pen/Fdnlz

I now need to make it functional but have 0 knowledge of php.我现在需要使其正常运行,但对 php 的了解为 0。 I've tried lots of different bits of php code, but I don't even know how to link the html file to the .php file properly.我尝试了很多不同的 php 代码,但我什至不知道如何正确地将 html 文件链接到 .php 文件。 My code is below, if anyone could tell me how to link the files I would be so so grateful!我的代码如下,如果有人能告诉我如何链接文件,我将非常感激!

HTML: 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 php

    <?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
?>

Thanks!谢谢! I finally sorted the problem, it turns out GitHub doesn't support php which is where I was hosting it我终于对问题进行了排序,结果 GitHub 不支持 php,这是我托管它的地方

First create a file called mail.php and place it within the same directory as your html/css file.首先创建一个名为 mail.php 的文件,并将它放在与 html/css 文件相同的目录中。

The mail.php file is responsible for processing your form and then sending it wherever you wish. mail.php 文件负责处理您的表单,然后将其发送到您希望的任何地方。 Save these files and simply test them on a web server like WAMP/LAMP/XAMP or a live server if you have one.保存这些文件,然后在 WAMP/LAMP/XAMP 等 Web 服务器或实时服务器(如果有)上简单地测试它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM