我的 php 腳本有問(wèn)題。對(duì) php 很陌生,所以我知道它不是最好的。提交表單時(shí)出現(xiàn)以下錯(cuò)誤。注意:未定義索引:第 6 行 C:\xampp\htdocs\AppX1\signin.php 中的用戶名 注意:第 7 行 C:\xampp\htdocs\AppX1\signin.php 中未定義索引:密碼 致命錯(cuò)誤:未捕獲錯(cuò)誤:調(diào)用 C:\xampp\htdocs\AppX1\signin.php:13 中未定義的函數(shù) mysql_real_escape_string() 堆棧跟蹤:第 13 行 C:\xampp\htdocs\AppX1\signin.php 中拋出 #0 {main}我讀過(guò)一些文章說(shuō)要使用一種isset方法,盡管我不確定該將其放在哪里或者它是否適用于我的情況。<form action="signin.php" id="signInForm"> <fieldset> <label class="fieldLabel" for="uname">Email Address</label> <input class="fieldInput" type="text" id="uname" name="username"> <label class="fieldLabel" for="pword">Password</label> <input class="fieldInput" type="password" id="pword" name="password"> <input class="submitBtn" type="submit" value="Submit"> </fieldset></form><?php $username = $_POST['username']; $password = $_POST['password']; // sql injection prevention $username = stripcslashes($username); $password = stripcslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); //connect to server and select SQLiteDatabase mysql_connect("localhost", "root", ""); mysql_select_db("user"); //query db for user $result = mysql_query("SELECT * FROM user where email = '$username' and password = '$password'") or die("Failed to query database ".mysql_error()); $row = mysql_fetch_array($result); if ($row['email'] == $username && $row['password'] == $password) { echo "Login Success!".$row['email']; } else { echo "Login Failed"; }?>
未定義索引:第 6 行 C:\xampp\htdocs\AppX1\signin.php 中的用戶名
BIG陽(yáng)
2023-08-21 17:46:46