Session MySQL PHP
member_login_do.php
/* Member Login Processing page */
Require_once (".. /conn/conn_db.php "); Include database link file
if ($_post["Txt_username"]!= "" && $_post["txt_pwd"]!= "")
{
$name = $_post["Txt_username"]; Get the submitted user name
$pwd = $_post["Txt_pwd"]; Get the submitted password
$STR = "SELECT * from member_info where m_name = ' $name ' and M_password = ' $pwd '"; Query statements
$result = mysql_query ($STR); Execute SQL statement
if (mysql_num_rows ($result) >0)//View the number of query result rows returned
{
session_id (SID);
Session_Start (); Login successful, set session value
$_session[' member '] = $_post[' txt_username '];
Session_write_close ();
echo "";
Exit (0);
}
Else
{
echo "";
}
}
Else
{
echo "";
}
?>
Reply to discussion (solution)
session_member_check.php
/* Member Landing judgment page */
if ($_session[' member ' = = "")//login to determine if no landing, then jump to the landing page
{
echo "";
}
Else
{
$membername = $_session[' member ');
echo "Welcome to Fujian-Taiwan Mall! ". $membername;
}
?>
After each landing can not jump to the member_info.php, are also appear landing box (member_login.php)
session_member_check.php
Don't you need a start?
I added it before the if judgment, but it's the same.
It seems that after the addition of warning, but a flash past, can not see clearly
Each program needs to have session_start (); You're only in member_login_do.php.
SID only has a value after session_start ()
Kiss and inject.
But add the session_start (); It's still the same, can't jump.
if (mysql_num_rows ($result) >0)//View the number of query result rows returned
{
Exit Did you get in here?
..................
You first find out whether the member_info.php jump to the member_login.php file or before the jump.
I added session_id (SID) at the beginning of several PHP files, session_start (), now the page can jump, but the member_info.php cannot display the information queried from the database?
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"); Include database link file $STR = "SELECT * from member_info where m_name = '". $_session[' Member ']. "'"; Query statements Echo $_session[' member ']; $arr = mysql_query ($STR); Execute SQL statement $result = Mysql_fetch_array ($arr); Get query Results ?>
Member Basic information |
User name: |
|
Password: |
|
Password protection issues: |
|
Password protection Answer: |
|
ID Number: |
|
Contact Phone: |
|
Qq: |
|
Mailbox: |
|
Contact Address: |
|
Zip code: |
|
Consumption amount: |
|
Balance: |
|
Registration time: |
|
|
Print_r ($result); What's the result?
I'll just switch to a browser.