Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么可以';我看不到联系表上的电子邮件地址吗?_Php_Html_Forms_Email_Contacts - Fatal编程技术网

Php 为什么可以';我看不到联系表上的电子邮件地址吗?

Php 为什么可以';我看不到联系表上的电子邮件地址吗?,php,html,forms,email,contacts,Php,Html,Forms,Email,Contacts,我收到一封电子邮件,但它将从未知地址读取。其他一切似乎都起作用了。这里有一个链接,指向我对php了解不多的页面 <?php if (isset($_POST['submit'])) { $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $mailTo = "contact@podmtg.com"; $headers = "From

我收到一封电子邮件,但它将从未知地址读取。其他一切似乎都起作用了。这里有一个链接,指向我对php了解不多的页面

    <?php

if (isset($_POST['submit'])) {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];

    $mailTo = "contact@podmtg.com";
    $headers = "From: ".$mailFrom;
    $txt = "You have recieved an email from ".$name.".\n\n".$message;

    mail($mailTo, $subject, $txt, $headers);

    header("Location: contact.html?mailsend");
}

?>

<form action="contactform.php" method="post" onsubmit="return confirm('Are you sure you want to submit this form?');">
             <input type="text" name="name" placeholder="Name" required="required">
             <input type="text" name="email" placeholder="Email" required="required">
             <textarea name="message" placeholder="Write message here..." required="required"></textarea>
             <button type="submit" name="submit">SUBMIT</button>
        </form>

提交

在本文中,您提到了“$headers=“From:”.$mailFrom;但找不到$mailFrom。使用$email代替$mailFrom。

我更改了代码。你们是对的。谢谢大家!

    <?php

if (isset($_POST['submit'])) {
    $name = $_POST['name'];
    $mailFrom = $_POST['email'];
    $message = $_POST['message'];

    $mailTo = "contact@podmtg.com";
    $headers = "From: ".$mailFrom;
    $txt = "You have recieved an email from ".$name.".\n\n".$message;

    mail($mailTo, $headers, $txt);

    header("Location: index.html?mailsend");
}

?>


$email
!=
$mailFrom
$email具有电子邮件地址,但您正在尝试从$emailFrom读取。我想知道为什么它不抛出异常。$mailFrom未定义。