简体   繁体   English

无法让我的 php 为联系表格工作

[英]can't get my php to work for a contact form

I made my contact form on a contact.html page and in form I put action="mail.php" and then I made a mail.php page.我在 contact.html 页面上制作了我的联系表格,并在表单中输入了 action="mail.php",然后我制作了一个 mail.php 页面。 once I put all my php in the page my send button wouldn't work.一旦我把我所有的 php 放在页面中,我的发送按钮就不起作用了。 and yes I have tried making my contact.html page contact.php but my website won't open that link up at all.是的,我已经尝试使我的 contact.html 页面 contact.php 但我的网站根本无法打开该链接。 I'm using atom.我正在使用原子。 need help.需要帮忙。 asking for a friend.问一个朋友。

I need the right php for the contact form so I can be able to get an email when someone submits a form.我需要为联系表单使用正确的 php,这样我才能在有人提交表单时收到电子邮件。

Here is my Contact.html page:这是我的 Contact.html 页面:

 <!DOCTYPE html>
 <html>
 <head>
    <meta charset="utf-8">
    <title>ITA</title>
    <link rel="stylesheet" type="text/css" href="style.css">
    <link href="https://fonts.googleapis.com/css family=Poppins&display=swap" rel="stylesheet">

</head>

<header>

<div class="container">

<img src="../pics/LogoMakr_89l9j5.png" alt="logo" class="logo">

<nav>
  <ul>
      <li><a href="index.html">Home</a></li>
      <li><a href="products.html">Products</a></li>
      <li><a href="about.html">About</a></li>
      <li><a href="contact.html">Contact</a></li>
  </ul>
</nav>

 </div>


 </header>

<form action="mail.php" method="post">

  <body class="contactbgimg">

<div class="contact-form">
  <h1>Contact Us</h1>

<div class="txtb">
  <label>Full Name :</label>
  <input type="text" placeholder="Enter Your Name" required>
</div>

<div class="txtb">
  <label>Email :</label>
  <input type="email" placeholder="Enter Your Email" required>
</div>

<div class="txtb">
  <label>Phone Number :</label>
  <input placeholder="Enter Your Phone Number" required>
</div>

<div class="txtb">
  <label>Message:</label>
   <input type="text" placeholder="Enter Text" required>
  <textarea></textarea>
</div>

<input class="btn" type="submit" value="Send" name="Submit">

</form>

    <script src="index.js"></script>
</body>

</html>

You may try this:你可以试试这个:

1) contact.php 1) 联系.php

<!DOCTYPE html>
 <html>
 <head>
    <meta charset="utf-8">
    <title>ITA</title>
    <link rel="stylesheet" type="text/css" href="style.css">
    <link href="https://fonts.googleapis.com/css family=Poppins&display=swap" rel="stylesheet">

</head>
<header>

<div class="container">
<img src="../pics/LogoMakr_89l9j5.png" alt="logo" class="logo">
    <nav>
        <ul>
            <li><a href="index.html">Home</a></li>
            <li><a href="products.html">Products</a></li>
            <li><a href="about.html">About</a></li>
            <li><a href="contact.html">Contact</a></li>
        </ul>
    </nav>
</div>
</header>
<body class="contactbgimg">
<form action="mail.php" method="post">
<div class="contact-form">
<h1>Contact Us</h1>

    <div class="txtb">
        <label>Full Name :</label>
        <input type="text" name="fullname" placeholder="Enter Your Name" required>
    </div>

    <div class="txtb">
        <label>Email :</label>
        <input type="email" name="email" placeholder="Enter Your Email" required>
    </div>

    <div class="txtb">
        <label>Phone Number :</label>
        <input type="text" name="contactno" placeholder="Enter Your Phone Number" required>
    </div>

    <div class="txtb">
        <label>Message:</label>
        <input type="text" placeholder="Enter Text" required>
        <textarea></textarea>
    </div>

    <input class="btn" type="submit" name="Submit">
</div>
</form>
<script src="index.js"></script>
</body>

</html>

2) mail.php 2) 邮件.php

<?php
if(isset($_POST['Submit'])){
    $fullname = $_POST['fullname'];
    $email = $_POST['email'];
    $contactno = $_POST['contactno'];
    //All your Business logic goes here.

    echo "Name : ".$fullname."<br>Email ID :".$email."<br>Contact # :".$contactno;
}

?>

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

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