Why is the value transmitted by session null? Session MySQL php
Member_login_do.php
/* Member Login processing page */
Require_once ("../conn/Conn_DB.php"); // contains the database link file
If ($ _ POST ["txt_username"]! = "" & $ _ POST ["txt_pwd"]! = "")
{
$ Name = $ _ POST ["txt_username"]; // Obtain the submitted user name
$ Pwd = $ _ POST ["txt_pwd"]; // Obtain the submitted password
$ Str = "select * from Member_Info where M_Name = '$ name' and M_Password =' $ pwd'"; // query statement
$ Result = mysql_query ($ str); // execute an SQL statement
If (mysql_num_rows ($ result)> 0) // view the number of returned query results
{
Session_id (SID );
Session_start (); // login successful, set the SESSION value
$ _ SESSION ['member'] = $ _ POST ['txt _ username'];
// Session_write_close ();
Echo "script window. location. href = '../member_info.php'; script";
// Exit (0 );
}
Else
{
Echo "script alert ('user name or password is incorrect! '); Window. location. href =' ../member_login.php 'script ";
}
}
Else
{
Echo "script" alert ('Enter your username and password! '); Window. location. href =' ../member_login.php 'script ";
}
?>
Reply to discussion (solution)
Session_member_check.php
/* Member logon judgment page */
If ($ _ SESSION ['member'] = "") // you can log on to the apsaradb for Memcached page.
{
Echo "script window. location. href = 'Member _ login. php'; script";
}
Else
{
$ Membername = $ _ SESSION ['member'];
// Echo "Welcome to Mintai mall! ". $ Membername;
}
?>
After each login, you cannot jump to member_info.php. the login box (member_login.php) appears again)
Session_member_check.php
Do you not need start?
I added it before if judgment, but it is still the same
It seems that there will be a warning after it is added, but it is too flash to see clearly
Each program requires session_start (); you cannot do it only in member_login_do.php.
SID has a value only after session_start ().
Injection
However, if session_start () is added, it is still the same and cannot be redirected.
If (mysql_num_rows ($ result)> 0) // view the number of returned query results
{
Exit; // is it here?
..................
First, you need to know whether to jump to the member_login.php file in member_info.php or before.
I have added session_id (SID); session_start () to the beginning of several php files. now the page can jump, but the information queried from the database cannot be displayed in member_info.php?
Member_info.php
Member Center
Member Center |
Session_id (SID ); Session_start (); Require_once ("action/session_member_check.php");?> |
|
Require_once ("conn/Conn_DB.php"); // contains the database link file $ Str = "select * from Member_Info where M_Name = '". $ _ SESSION ['member']. "'"; // query statement Echo $ _ SESSION ['member']; $ Arr = mysql_query ($ str); // execute an SQL statement $ Result = mysql_fetch_array ($ arr); // Obtain the query result ?>
Basic member information |
User name: |
|
Password: |
|
Password protection problems: |
|
Password protection answer: |
|
ID number: |
|
Contact number: |
|
QQ: |
|
Email: |
|
Contact address: |
|
Zip code: |
|
Consumption amount: |
|
Balance: |
|
Registration time: |
|
|
Print_r ($ result); what is the result?
I changed to a browser.