All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
asp.net程序中实现checkbox全选代码_[Asp.Net教程]
SQL循序渐进(6)-------删除表_[SQL,Server教程]
asp.net控件CheckBoxList使用详解_[Asp.Net教程]
Ajax清理缓存_[XML教程]
按比例微缩图片的一段小小的JS代码_JavaScript技术_编程技术
.NET数据库应用程序中存储过程的应用_[Asp.Net教程]
轻松掌握SQL,Sever中各种语句的完整语法_mssql学习_编程技术
PHP判断数字,汉字和英文_php资料_编程技术
ASP.NET技巧:远程抓取GOOGLE的自动翻译结果_.net资料_编程技术
探讨一种AJAX性能的改进方法_[Asp.Net教程]
Reading number is top 10 pictures
非常漂亮的泳装美女
Green sweet joey wong young old photos exposure
玩手机对身体不好
Small s breast enhancement demonstration
A man's favorite things8
Discharge accidentally Actresses by the breast2
清纯性感的美眉1
Fury xp desktop theme
Compared GDP and per capita income in China for 40 years
A cat have life principles
Download software ranking
Prostitutes diary
WebService在.NET中的实战应用教学视频 → 第4集
Call Of Duty5
Sora aoi - one of more PK
Boxer's Top ten classic battle6
虚拟机5.5.3版
实战黑客不求人
Unix video tutorial8
jdk1.6 for windows
The Bermuda triangle3
aaa published in(发表于) 2013/12/21 22:37:15 Edit(编辑)
如何在十天内学会php之第七天_php资料_编程技术

如何在十天内学会php之第七天_php资料_编程技术

如何在十天内学会php之第七天_php资料_编程技术-你的首页-uuhomepage.com

学习目的:学会SESSION的使用

SESSION的作用很多,最多用的就是站点内页面间变量传递。在页面开始我们要session_start();开启SESSION;
然后就可以使用SESSION变量了,比如说要赋值就是:$_SESSION['item']="item1";要得到值就是$item1=$_SESSION['item'];,很简单吧。这里我们可能会使用到一些函数,比如说判断是不是某SESSION变量为空,可以这么写:empty($_SESSION['inum'])返回true or false。

下面综合一下前面所说的我们来看一个登陆程序,判断用户名密码是否正确。
登陆表单是这样:login.php
<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">
<td colspan="2"><div align="center">Administrators Login</div></td>
</tr>
<tr class="tdbg">
<td><div align="center">Username</div></td>
<td><div align="center">
<input name="username" type="text" id="username">
</div></td>
</tr>
<tr class="tdbg">
<td><div align="center">Password</div></td>
<td><div align="center">
<input name="password" type="password" id="password">
</div></td>
</tr>
<tr class="tdbg">
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Clear">
</div></td>
</tr>
</table></td></form>
</tr>
</table>

处理文件是这样
<?
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 "<script>alert('Password Check Error!');location.href='login.php';</script>";
}
}
else
{
echo "<script>alert('Username Check Error!');location.href='login.php';</script>";
}
}
else
{
echo "<script>alert('Database Connection Error!');location.href='login.php';</script>";
}

?>

conn.php是这样:
<?
$conn=mysql_connect ("127.0.0.1", "", "");
mysql_select_db("shop");
?>

由于 $_SESSION['adminname']=$username;我们可以这样写验证是否登陆语句的文件:checkadmin.asp
<?
session_start();
if($_SESSION['adminname']=='')
{
echo "<script>alert('Please Login First');location.href='login.php';</script>";
}
?>

呵呵,今天说到这里,明天说一下怎么弄一个分页。

PS:写拉一大堆的代码,希望看到的朋友可以明白写的是什么,需要和我交流的到www.redsec.org的论坛和我联系




添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.