form.html
<form name="input" action="process.php" method="post">
<input type="text" name="user" placeholder="Enter Your Name">
<input type="text" name="message" placeholder="Enter A Message">
<br>
<input class="shout-btn" type="submit" name="submit" value="Shout It Out">
</form>
process.php
<?php
include "database.php";
echo var_dump($_POST);
if(isset($_POST['submit'])){
$user = mysqli_real_escape_string($con,$_POST['user']);
$message = mysqli_real_escape_string($con,$_POST['message']);
//SET TIMEZONE
date_default_timezone_set('America/New_York');
$time = date('h:i:s a',time());
if (!isset($user) || $user == "" || !isset($message) || $message == "") {
echo "bad";
} else {
echo "good";
}
}
?>
出于某种原因,$_POST
为我提供了文字变量:
array(3) { ["text"]=> string(5) "david" ["message"]=> string(27) "adasdasdasdasdasd asdasdasd" ["submit"]=> string(12) "Shout It Out" }
注意:未定义的索引:第6行的D:\ xampp \ htdocs \ php \ shoutit \ process.php中的用户 坏
答案 0 :(得分:0)
您是否在SO上正确地重新输入了form.html并且您的实际代码中存在错误(主要是调用名称字段文本),或者您是这样的,然后修复它并且您的浏览器正在缓存旧版本。
轻松检查,在浏览器中查看表单上的源并检查表单名称。 清除缓存并重试。