|
 |
|
ตัวแปร session อ่ะครับ ผมู้ อยากเรียก ให้ มัน แสดงได้ทุหน้าสามารถทำได้ไหมครับ |
|
 |
|
|
 |
 |
|
มันก็เรียกทุกหน้าอยู่แล้ว นิคับ เพียงเราแค่ประกาศ session_start(); ไว้บนสุด
|
 |
 |
 |
 |
Date :
2011-04-07 10:42:05 |
By :
TEST |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แค่ประกาศไว้หน้าเดียว ก้ สามารถเรียกได้ทุกเพส เลยหรอครับ หรือ จะสามารถเรีกได้เฉพาะ หน้าที่ มันPOST ไป ครับ
|
ประวัติการแก้ไข 2011-04-07 10:58:21
 |
 |
 |
 |
Date :
2011-04-07 10:56:31 |
By :
macro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถามถึง session ใช่ไหมคับ
ก็แค่ ประกาศ session_start(); ไว้บนสุด ของทุก page ที่คุณจะเรียกใช้คับ
|
 |
 |
 |
 |
Date :
2011-04-07 11:06:59 |
By :
TEST_CODE |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
นั้น ล่ะครับ มัน ไม่ได้ ล่ะซิ ครับ
ช่วยดู ที่ ครับ
1. อันนี้ หน้า เช๊ค user ครับ
Code (PHP)
<?
session_start ;
$host = "127.0.0.1";
$user = "root";
$password = "12345";
$dbname = "rimes1";
mysql_connect($host,$user,$password) or die("ติดต่อ Host ไม่ได้");
mysql_select_db($dbname) or die ("ติดต่อฐานข้อมูลไม่ได้");
$logname=$_POST['logname'];
$pw=$_POST['pw'];
//session_register ("$logname");
//session_register (" $pw");
$_SESSION['logname'] = $logname;
$_SESSION['pw'] =$pw;
session_write_close();
echo $_SESSION['logname'];
echo $_SESSION['pw'];
$sql = " SELECT * FROM user_table WHERE username='$logname' AND password = '$pw'";
$dbquery = mysql_db_query($dbname,$sql);
$row = mysql_fetch_array($dbquery);
$num_rows = mysql_num_rows($dbquery);
if($num_rows==1)
{
if($row['password']==$pw && $row['username']==$logname){
}else{
}
echo "<script>alert('patience.....');window.location=' main.php';</script>";
}
else
{
print "<script>alert('Password fail');window.location=' formlogin.php';</script>";
}
?>
2. อัน นี้หน้าที่ ต้องการให้โชว์ ชื้อ ครับ
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>Untitled Document</title>
</head>
<h1>Main</h1>
<body>
<h1>Main</h1>
<form action="checkuser.php">
<?
session_start ;
echo $_SESSION['logname'];
echo $lognameagin ;
?>
</form>
<p><a href="insertandedit.php">Insert And edit </a></p>
<p><a href="selectbynamecom.php">Search</a></p>
<p><a href="formlogin.php">backtologin</a></p>
</body>
</html>
ช่วยทีน่ะครับ
|
ประวัติการแก้ไข 2011-04-07 11:11:37 2011-04-07 11:13:15
 |
 |
 |
 |
Date :
2011-04-07 11:09:08 |
By :
macro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<?
session_start();
$host = "127.0.0.1";
$user = "root";
$password = "12345";
$dbname = "rimes1";
mysql_connect($host,$user,$password) or die("ติดต่อ Host ไม่ได้");
mysql_select_db($dbname) or die ("ติดต่อฐานข้อมูลไม่ได้");
$logname=$_POST['logname'];
$pw=$_POST['pw'];
//session_register ("$logname");
//session_register (" $pw");
$_SESSION['logname'] = $logname;
$_SESSION['pw'] =$pw;
session_write_close();
echo $_SESSION['logname'];
echo $_SESSION['pw'];
$sql = " SELECT * FROM user_table WHERE username='$logname' AND password = '$pw'";
$dbquery = mysql_db_query($dbname,$sql);
$row = mysql_fetch_array($dbquery);
$num_rows = mysql_num_rows($dbquery);
if($num_rows==1)
{
if($row['password']==$pw && $row['username']==$logname){
}else{
}
echo "<script>alert('patience.....');window.location=' main.php';</script>";
}
else
{
print "<script>alert('Password fail');window.location=' formlogin.php';</script>";
}
?>
<? session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>Untitled Document</title>
</head>
<h1>Main</h1>
<body>
<h1>Main</h1>
<form action="checkuser.php">
<?
//session_start ; // ไว้บนสุดเลยคับ
$lognameagin = $_SESSION['logname'];
echo $lognameagin ;
?>
</form>
<p><a href="insertandedit.php">Insert And edit </a></p>
<p><a href="selectbynamecom.php">Search</a></p>
<p><a href="formlogin.php">backtologin</a></p>
</body>
</html>
|
ประวัติการแก้ไข 2011-04-07 11:17:33
 |
 |
 |
 |
Date :
2011-04-07 11:12:46 |
By :
TEST_CODE |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ส่งให้แล้ว น่ะครับ
|
 |
 |
 |
 |
Date :
2011-04-07 11:13:42 |
By :
macro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หน้าแรก
Code (PHP)
<?
session_start();
$host = "127.0.0.1";
$user = "root";
$password = "12345";
$dbname = "rimes1";
mysql_connect($host,$user,$password) or die("ติดต่อ Host ไม่ได้");
mysql_select_db($dbname) or die ("ติดต่อฐานข้อมูลไม่ได้");
$logname=$_POST['logname'];
$pw=$_POST['pw'];
//session_register ("$logname");
//session_register (" $pw");
$_SESSION['logname'] = $logname;
$_SESSION['pw'] =$pw;
session_write_close();
echo $_SESSION['logname'];
echo $_SESSION['pw'];
$sql = " SELECT * FROM user_table WHERE username='$logname' AND password = '$pw'";
$dbquery = mysql_db_query($dbname,$sql);
$row = mysql_fetch_array($dbquery);
$num_rows = mysql_num_rows($dbquery);
if($num_rows==1)
{
if($row['password']==$pw && $row['username']==$logname){
}else{
}
echo "<script>alert('patience.....');window.location=' main.php';</script>";
}
else
{
print "<script>alert('Password fail');window.location=' formlogin.php';</script>";
}
?>
หน้าแสดง
Code (PHP)
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>Untitled Document</title>
</head>
<h1>Main</h1>
<body>
<h1>Main</h1>
<form action="checkuser.php">
<?
echo $_SESSION['logname'];
echo $lognameagin ;
?>
</form>
<p><a href="insertandedit.php">Insert And edit </a></p>
<p><a href="selectbynamecom.php">Search</a></p>
<p><a href="formlogin.php">backtologin</a></p>
</body>
</html>
|
 |
 |
 |
 |
Date :
2011-04-07 11:23:04 |
By :
ไวยวิทย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังไม่ได้อ่ะครับ - -"
เหมือนกัน ว่า ค่าของ session มัน ไม่ คง หรือไปทำงานอีก หน้า อ่ะครับ
|
ประวัติการแก้ไข 2011-04-07 11:33:51
 |
 |
 |
 |
Date :
2011-04-07 11:28:40 |
By :
macro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยที น่ะครับ ผม หัว ฟู ไปหมดแล้ว
|
 |
 |
 |
 |
Date :
2011-04-07 13:36:27 |
By :
macro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|