十天学会php之第七天
[b][color=#ff6600] [/color][/b][color=#000000][font=宋体][size=10.5pt]学习目的:学会[/size][/font]SESSION[font=宋体][size=10.5pt]的使用[/size][/font][/color](SmE%bOu;d
[color=#000000]SESSION[/color][color=#000000][font=宋体][size=10.5pt]的作用很多,最多用的就是站点内页面间变量传递。在页面开始我们要[/size][/font]session_start();[font=宋体][size=10.5pt]开启[/size][/font]SESSION[font=宋体][size=10.5pt];[/size][/font][/color]
[color=#000000][font=宋体][size=10.5pt]然后就可以使用[/size][/font]SESSION[font=宋体][size=10.5pt]变量了,比如说要赋值就是:[/size][/font]$_SESSION['item']="item1";[font=宋体][size=10.5pt]要得到值就是[/size][/font]$item1=$_SESSION['item'];[font=宋体][size=10.5pt],很简单吧。这里我们可能会使用到一些函数,比如说判断是不是某[/size][/font]SESSION[font=宋体][size=10.5pt]变量为空,可以这么写:[/size][/font]empty($_SESSION['inum'])[font=宋体][size=10.5pt]返回[/size][/font]true or false[font=宋体][size=10.5pt]。[/size][/font][/color]J%M l,K(v W%qm
[font=宋体][size=10.5pt][color=#000000]下面综合一下前面所说的我们来看一个登陆程序,判断用户名密码是否正确。[/color][/size][/font]m@)I2blbe
[font=宋体][size=10.5pt][color=#000000]登陆表单是这样:[/color][/size][/font][color=#000000]login.php5Y5eU5F\ Z
<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<form action="checklogin.php" method="post"><td align="center" valign="middle"><table width="400" border="0" cellpadding="5" cellspacing="1" class="tablebg">
<tr class="tdbg">8J5Y ~&e,@f'A
<td colspan="2"><div align="center">Administrators Login</div></td>
</tr>]9?&|7L"~.Hvwi
<tr class="tdbg">&MG4Y`7f/N
<td><div align="center">Username</div></td>
<td><div align="center">!_1Q:fAHI W
<input name="username" type="text" id="username">
</div></td>Z1Y S#G'n*R ].m
</tr>
<tr class="tdbg">
<td><div align="center">Password</div></td>P7|T2G2EV
<td><div align="center">$RN"d`y|#_e2W P)^
<input name="password" type="password" id="password">4| [[T-BPk
</div></td>
</tr>8Q*wM |0j8_
<tr class="tdbg">O3_f-vye$p ?;TV
<td colspan="2"><div align="center">IL7m?2YH
<input type="submit" name="Submit" value="Submit">