所以我正在使用 php 制作一個登錄表單,每次提交時(shí)我都會收到未定義的索引錯誤。這是我的表格: <form action="website.net/validation.php" method="post" enctype="multipart/form-data"> <div class="form-group"> <label>Username</label> <input type="text" maxlength="255" placeholder="Username" name="user" class="form-control" required /> </div> <div class="form-group"> <label>Password</label> <input type="password" maxlength="255" placeholder="Password" name="password" class="form-control" required /> </div> <hr class="my-4"> <div class="form-group"> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" id="customCheck1" name="remember" value="yes"> <label class="custom-control-label" for="customCheck1">Remember Me</label> </div> </div> <br> <p class="lead"> <button type="submit" class="btn btn-primary btn-lg">Login</button> </p> </form>繼承人的PHP:$name = stripslashes($_POST["user"]);$pass = stripslashes($_POST["password"]);這顯然只是意味著我拼錯了某些東西或者沒有設(shè)置值,對吧?錯誤的。我檢查了我在 html 和 php 中的所有拼寫,我也已經(jīng)完成var_dump($_POST["user"]);并打印出用戶名。表單元素是必需的,因此不能不設(shè)置它們。我試過用 htmlentities() 包圍變量。我試過將它們包圍在 if then 塊中以測試 ifset。沒有什么能解決這個問題。我不知道為什么這不起作用。有人可以幫忙嗎?謝謝整個 php 錯誤:<?phpini_set('display_errors', 1);ini_set('display_startup_errors', 1);error_reporting(E_ALL);session_start();var_dump($_POST);$name = stripslashes($_POST["user"]);$pass = stripslashes($_POST["password"]);
1 回答

互換的青春
TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超6個贊
這個問題看起來很奇怪,但一個好的起點(diǎn)是回應(yīng)服務(wù)器似乎看到的內(nèi)容(完全結(jié)構(gòu)化)。這可以這樣做:
echo "<pre>";
print_r($_POST);
echo "</pre>";
并且看到您正在使用 enctype="multipart/form-data",您還可以轉(zhuǎn)儲 $_FILES。但我有一種感覺,它可能是兩件事之一:行動領(lǐng)域或 stripslashes。對于最后一個選項(xiàng),為什么不在清潔之前先摘下它們,然后再清潔。對于第一個選項(xiàng),您可以將操作字段更改為明確的本地字段嗎:
<form action="validation.php" method="post" enctype="multipart/form-data">
- 1 回答
- 0 關(guān)注
- 105 瀏覽
添加回答
舉報(bào)
0/150
提交
取消