数据库中未定义的变量[关闭](Undefined variable in Database [closed])

编程入门 行业动态 更新时间:2024-10-22 15:39:08
数据库中未定义的变量[关闭](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!

更多推荐

本文发布于:2023-07-08 19:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1080236.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库中   变量   未定义   Undefined   Database

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!