ѧϰĿµÄ£ºÑ§»aSESSIONµÄʹÓÃ
SESSIONµÄ×÷Óúܶa£¬×i¶aÓõľÍÊÇÕ¾µaÄÚÒ³Ãae¼a±aÁ¿´«µÝ¡£ÔÚÒ³Ãae¿ªÊ¼ÎÒÃÇÒªsession_start();¿ªÆoSESSION£»
È»ºo¾Í¿ÉÒÔʹÓÃSESSION±aÁ¿ÁË£¬±ÈÈç˵Ҫ¸³Öµ¾ÍÊÇ£º$_SESSION['item']="item1";ÒªµÃµ½Öµ¾ÍÊÇ$item1=$_SESSION['item'];£¬ºÜ¼oµ¥°É¡£ÕaÀiÎÒÃÇ¿ÉÄÜ»aʹÓõ½Ò»Ð(C)º¯Êý£¬±ÈÈç˵ÅжÏÊDz»ÊÇijSESSION±aÁ¿Îª¿Õ£¬¿ÉÒÔÕaôд£ºempty($_SESSION['inum'])*µ»Øtrue or false¡£
ÏÂÃae×ÛºÏÒ»ÏÂÇ°ÃaeËu˵µÄÎÒÃÇÀ´¿´Ò»¸oµÇ½³ÌÐo£¬ÅжÏÓû§ÃuÃÜÂeÊÇñÕýÈ¡£
µÇ½±iµ¥ÊÇÕaÑu£ºlogin.php
´¦ÀiÎļþÊÇÕaÑu
<?
require_once('conn.php');
session_start();
$username=$_POST['username'];
$password=$_POST['password'];
$exec="select * from admin where username='".$username."'";
if($result=mysql_query($exec))
{
if($rs=mysql_fetch_object($result))
{
if($rs->password==$password)
{
$_SESSION['adminname']=$username;
header("location:index.php");
}
else
{
echo "";
}
}
else
{
echo "";
}
}
else
{
echo "";
}
?>
conn.phpÊÇÕaÑu£º
<?
$conn=mysql_connect ("127.0.0.1", "", "");
mysql_select_db("shop");
?>
ÓÉÓÚ $_SESSION['adminname']=$username;ÎÒÃÇ¿ÉÒÔÕaÑuдÑeÖ¤ÊÇ*ñµÇ½Ói¾aµÄÎļþ£ºcheckadmin.asp
<?
session_start();
if($_SESSION['adminname']=='')
{
echo "";
}
?>
ºÇºÇ£¬½ñÌi˵µ½ÕaÀi£¬Ã÷Ìi˵һÏÂÔoôŪһ¸o*ÖÒ³¡£