PHP Post 变量出现问题

这很难解释,但我在 PHP 中的 Post 变量方面遇到了一些问题。问题是我一直在 Repl.it 上制作一个虚拟网站来练习 PHP,因为我是一个完全的初学者,所以我一直在尝试联系表格。这是文件名“contact-form-handler.php”的 PHP 代码:


<?php


  $name = $_Post["name"];   $visitor_email = $_Post["email"];   $message = $POST['message'];



  $email_from = "19braja@rgshw.com";


  $email_subject = "New Form Submission For BXRSTUDIOS";


  $email_body = "User Name: $name.\n ".

                  "User Email: $visitor_email.\n".

                    "User Message $message.\n";



  $to = "19braja@rgshw.com";


  $headers = "From: $email_from \r\n";


  $headers = "Reply-To: $visitor_email \r\n";


  mail($to,$email_subject,$email_body,$headers);


  header("Location: contact.html");



?>

这是文件名为“contact.html”的 HTML 代码:


<html>

<head>

  <link href="contact.css" rel="stylesheet" type="text/css" />

  <title>Contact Form</title>

</head>

<body>

  <div class="contact-title">

    <h1> Want To Contact Us?</h1>

    <h2> We are always here to help</h2>

  </div>


  <div class="contact-form">

    <form id ="contact=form" method="post" action="contact-form-handler.php">

      <input name="name" type="text" class="form-control" placeholder="Your Name" required><br>

      <input name="email" type="email" class="form-control" placeholder="Your Email" required><br>


          <textarea name="message" type="text" class="form-control" placeholder="Message to BXRSTUDIOS" row="4" required></textarea><br>

          <input type="submit" class="form-control submit" value="SUBMIT MESSAGE">

          <p class="back">Not what you needed?<a href="index.php"> Go Back</a>

            </p>

    </form>

  </div>




</body>

</html>

有谁知道为什么 Post 变量不起作用?这是控制台上的内容:



Qyouu
浏览 95回答 1
1回答

鸿蒙传说

$_Post 变量无效,$_POST 是保留的系统变量,并且必须全部大写。所以你的代码应该是:$name&nbsp;=&nbsp;$_POST["name"];&nbsp;&nbsp;&nbsp;$visitor_email&nbsp;=&nbsp;$_POST["email"];&nbsp;&nbsp;&nbsp;$message&nbsp;=&nbsp;$_POST['message'];
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Html5