这很难解释,但我在 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 变量不起作用?这是控制台上的内容:
1 回答
鸿蒙传说
TA贡献1865条经验 获得超7个赞
$_Post 变量无效,$_POST 是保留的系统变量,并且必须全部大写。
所以你的代码应该是:
$name = $_POST["name"]; $visitor_email = $_POST["email"]; $message = $_POST['message'];
- 1 回答
- 0 关注
- 93 浏览
添加回答
举报
0/150
提交
取消