简体   繁体   English

HTML/PHP 电子邮件表单只发送一个字

[英]HTML/PHP Email Form just sending one word

None of the other questions have resolved my problem.其他问题都没有解决我的问题。 The problem is: I have an html email form, with php, when I click submit to test it sends, but it only sends one word , and that word is: From .问题是:我有一个带有 php 的 html 电子邮件表单,当我单击提交以测试它发送时,但它只发送一个单词,该单词是: From (they are all in the same email.php file). (它们都在同一个email.php文件中)。 Here is the form alone:这是单独的表格:
PHP: PHP:

    <?php

    if($_POST["message"]) {
                
        mail("my email", "Feedback for website",
                    
        $_POST["$message"]. "From: $email");
                
    }
                
?>

HTML /JS: HTML /JS:

<form method="post">
                <h2>Name</h2>
                <input type="name" id="name" placeholder="Bill Gates" autocorrect="off" autocapitalize="off" spellcheck="false" required/>
                
                <h2>Email</h2>
                    <input type="email" id="email" placeholder="Big-Gates@thesam.co.nz" alt="try loading page again." autocorrect="off" autocapitalize="off" spellcheck="false" name="email" required/>
                <h2>Feedback:</h2>
                <textarea name="message" required></textarea><br>
                
                <button type="submit" onclick="completeFunc()">Submit</button>
            
            </form>

Thanks :)谢谢 :)

You're using the wrong word in PHP code.您在 PHP 代码中使用了错误的词。

Wrong:错误的:

<?php
   if($_POST["message"]) {
       mail("my email", "Feedback for website",
       $_POST["$message"]. "From: $email");
   }
?>

Correct:正确的:

<?php
   if($_POST["message"]) {
       mail("my email", "Feedback for website",
       $_POST["message"]. "From: $email");
   }
?>

Difference: You using $_POST["$message"] but it should be $_POST["message"] .区别:您使用$_POST["$message"]但它应该是$_POST["message"]

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

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