数据库中未定义的变量[关闭](Undefined variable in Database [closed])
注意:未定义的变量:第16行的D:\ xampp \ htdocs \ Databasetesting \ Checklogin.php中的mypassword
我的第16行在这里:
$mypassword = stripslashes($mypassword);
这是我的整个代码,我将它用于Html5。
<?php session_start(); ob_start(); $host="localhost"; $username="jerome"; $password="jeromedizon"; $db_name="portal_database"; $tbl_name="members"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select Database mebers"); $mystudnum = mysql_real_escape_string($_POST['studnum']); $password = mysql_real_escape_string(md5($_POST['password'])); $mystudnum = stripslashes($mystudnum); $mypassword = stripslashes($mypassword); $mystudnum = mysql_real_escape_string($mystudnum); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE studnum='$mystudnum' and password='$mypassword'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ $_SESSION['mystudnum'] = $mystudnum; $_SESSION['password'] = $mypassword; header("location: Home.php"); } ob_end_flush(); ?>Notice: Undefined variable: mypassword in D:\xampp\htdocs\Databasetesting\Checklogin.php on line 16
and my Line 16 is here:
$mypassword = stripslashes($mypassword);
and here is my Entire Code i use this for Html5.
<?php session_start(); ob_start(); $host="localhost"; $username="jerome"; $password="jeromedizon"; $db_name="portal_database"; $tbl_name="members"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select Database mebers"); $mystudnum = mysql_real_escape_string($_POST['studnum']); $password = mysql_real_escape_string(md5($_POST['password'])); $mystudnum = stripslashes($mystudnum); $mypassword = stripslashes($mypassword); $mystudnum = mysql_real_escape_string($mystudnum); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE studnum='$mystudnum' and password='$mypassword'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ $_SESSION['mystudnum'] = $mystudnum; $_SESSION['password'] = $mypassword; header("location: Home.php"); } ob_end_flush(); ?>最满意答案
您的第16行需要:
$mypassword = stripslashes($password);发生错误是因为在此行之前未定义$mypassword ,但确实是$password !
Your line 16 needs to be:
$mypassword = stripslashes($password);The error occurs because $mypassword is not defined before this line, but $password is indeed!
更多推荐
发布评论