Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法登录到成员区域_Php_Mysql - Fatal编程技术网

Php 无法登录到成员区域

Php 无法登录到成员区域,php,mysql,Php,Mysql,我没有被重定向到“login_success.php”。出于某种原因,我仍然停留在当前页面“checklogin.php”。有人有什么想法吗?谢谢 <?php ob_start(); $host=""; $username=""; $password=""; $db_name=""; $tbl_name=""; // Connect to server and select databse. mysql_connect("$host", "$username", "$passw

我没有被重定向到“login_success.php”。出于某种原因,我仍然停留在当前页面“checklogin.php”。有人有什么想法吗?谢谢

    <?php

ob_start();
$host="";
$username="";
$password="";
$db_name="";
$tbl_name="";

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from form 
$myusername=$_POST['myusername']; 
$mypassword=$_POST['mypassword']; 

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){

// Register $myusername, $mypassword and redirect to file "login_success.php"
session_start();
$_SESSION['myusername']=$myusername;
$_SESSION['mypassword']=$mypassword;
header("location:login_success.php");
}
else {
echo "Wrong Username or Password. Please try again.";
}
ob_end_flush();

?>
$_SESSION['myusername']==$myusername;
$_SESSION['mypassword']==$mypassword;
我没有被重定向到“login_success.php”。出于某种原因,我仍然停留在当前页面“checklogin.php”。有人有什么想法吗?谢谢

    <?php

ob_start();
$host="";
$username="";
$password="";
$db_name="";
$tbl_name="";

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from form 
$myusername=$_POST['myusername']; 
$mypassword=$_POST['mypassword']; 

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){

// Register $myusername, $mypassword and redirect to file "login_success.php"
session_start();
$_SESSION['myusername']=$myusername;
$_SESSION['mypassword']=$mypassword;
header("location:login_success.php");
}
else {
echo "Wrong Username or Password. Please try again.";
}
ob_end_flush();

?>
$_SESSION['myusername']==$myusername;
$_SESSION['mypassword']==$mypassword;
应该是

$_SESSION['myusername']=$myusername;
$_SESSION['mypassword']=$mypassword;

会话_寄存器已从PHP中删除。无需使用它-只需打开您的会话,并在代码顶部显示session_start。

您提供的代码与错误消息不匹配。我看不到您调用session_的注册位置。你能包括你所有的代码吗?