频道直达 - 专题 - 新闻 - 基础 - 高级 - 安装 - 技巧 - 数据库 - 手册 - PHP - Linux - Java - MySQL - Apache - 麻辣堂 - 狼盟 - Rails社群 - 搜索 - 下载 - 开源 - 论坛
PHP开发资源网 主页>开发技巧> 收藏此文 | 收藏本站 | 设为首页
优酷喜剧片, 招商加盟 迅雷看看, 传奇世界 传世私服 天龙八部新品上市营销策划 魔兽世界

生成sessionid和随机密码的例子

来源:www.phpres.com 作者:Angelover 出处:www.phpres.com 2007-7-8 09:28:29 进入讨论组
关 键 词: 生成sessionid和随机密码的例子

用这个可以来验证用户和生成随机密码--teaman
<?
//----------------------------------------------------
// Function GetSID()
//
// Parameters : $nSize number of caracters, default 24
// Return value : 24 caracters string
//
// Description : This function returns a random string
// of 24 caracters that can be used to identify users
// on your web site in a more secure way. You can also 
// use this function to generate passwords.
//----------------------------------------------------
function GetSID ($nSize=24) {
    
    // Randomize
    mt_srand ((double) microtime() * 1000000);
    for ($i=1; $i<=$nSize; $i++) {
 
 // if you wish to add numbers in your string, 
 // uncomment the two lines that are commented
 // in the if statement
 $nRandom = mt_rand(1,30);
 if ($nRandom <= 10) {
     // Uppercase letters
     $sessionID .= chr(mt_rand(65,90));
    //    } elseif ($nRandom <= 20) {
    //        $sessionID .= mt_rand(0,9);
 } else {
     // Lowercase letters
     $sessionID .= chr(mt_rand(97,122));
 }
 
    }        
    return $sessionID;
}
// Test the function 
echo GetSID(16);
?>欢迎进入PHP开发资源论坛讨论。
收藏此文】【 】【打印】【关闭
相关文章
图文推荐
论 坛 资 源
PHP开发资源网奋斗目标
阅读排行:
热门技术文档
最新图文档
本站编辑推荐:(本站开通Delphi4PHP专区,欢迎进入论坛交流!)
编缉最近更新文章
网站赞助商
搜索您感兴趣的内容
 
   网站首页 -  网站地图 -  网站合作 -  手册中心 -  通用网址 -  网站论坛 -  网站投稿 -  友情链接 -  帮助中心
版权所有:PHP开发资源网 © 2003-2008 通用网址:PHP资源网 合作媒体: 赛迪网IT技术
互联网违法和不良信息举报中心 | 不良信息举报信箱