<html>
<head>
<title>php教程写的网页计数器代码</title>
<head>
<body>
代码如下 | 复制代码 |
<?php // 图形模式计数 fclose ($fp); |
?>
</body>
</html>
代码如下 | 复制代码 |
// 连接数据库 // 判断该用户名是否已经存在 // 方法二:只保存文件名, if ($photo<>""){ mysql_query($sql,$conn) or die ("插入数据失败: ".mysql_error()); // 关闭连接 ?> 代码二 <?php // 判断该用户名是否已经存在 mysql_query($sql,$conn) or die ("插入数据失败: ".mysql_error()); // 关闭连接 |
<?php教程
session_start();
if(getconfig("chatroom_admin")==$_post["username"]&&getconfig("chatroom_adminpassword")==md5($_post["password"]))
{
//登陆成功,注册session
session_register("administrator");
if(isset($_session["hack_num"]))
{
session_unregister("hack_num");
}
$_session["administrator"] = "yes";
header("location:main.php");
exit;
}
else
{
if($_session["hack_num"]=="")
{
session_register("hack_num");
$_session["hack_num"] = 1;
}
else
{
$_session["hack_num"] ++;
}
header("location:../notice.php?id=".admin_login_lost);
exit;
}
?>
看到红色的没,那里就是用户登录成功把数据保存到session['hack_num']面。
<?php
//这个页面首先判断用户是否正确登录,如未登录,就转到登录页面。
session_start();
if((!$user_id)or(!$user_array[hack_num])or(!$user_array[hack_num])){
header("location: login.php3");
}
?>
上面这段代码是用来判断session['hack_num']是否有值了,有就是登录成功了。
本站原创转载注明来源http://www.111cn.net/phper/php.html
这是一款利用递归写的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.111cn.net/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=gb2312" /> <head> <style type="text/css教程"> <!-- .menu { color:#000000; font-size: 12px; cursor: hand;} </style> <script type="text/网页特效"> function showmenu(menuid) { if(menuid.style.display=="none") { menuid.style.display=""; } else { menuid.style.display="none"; } } </script> <title>电视树状目录</title> </head> <body> <?php $globals["id"] =1; $jibie=1; $sql="select * from tvmenu where bid=0"; $result=mysql教程_query($sql,$conn); if(mysql_num_rows($result)>0) treemenu($conn,$result,$jibie,$id); function treemenu($conn,$result,$jibie) //进入函数循环 { $numrows=mysql_num_rows($result); echo "<table cellpadding='0' cellspacing='0' border='0'>"; for($rows=0;$rows<$numrows;$rows++) { $menu=mysql_fetch_array($result); $sql="select * from tvmenu where bid=$menu[id]"; $result_sub=mysql_query($sql,$conn); echo "<tr>"; //如果该菜单项目有子菜单,则添加javascript onclick语句 if(mysql_num_rows($result_sub)>0) { echo "<td width='20'><img" width=100% src='+.gif' border='0'></td>"; echo "<td class='menu' onclick='javascript:showmenu(menu".$globals["id"].");'>"; } else { echo "<td width='20'><img" width=100% src='-.gif' border='0'></td>"; echo "<td class='menu'>"; } if($menu[url]!="") echo "<a href='$menu[url]'>$menu[name]</a> "; else echo "<a href='#'>$menu[name]</a> <a href='?b={$menu[id]}&tpye=add'> 添加</a> <a href='?b={$menu[id]}&tpye=edit'> 编辑</a> <a href='?b={$menu[id]}&action=del'> 删除</a>"; echo "</td> </tr>"; if(mysql_num_rows($result_sub)>0) { echo "<tr id=menu".$globals["id"]++." style='display:none'>"; echo "<td width='20'> </td>"; echo "<td>"; //将级数加1 $jibie++; treemenu($conn,$result_sub,$jibie); $jibie--; echo "</td></tr>"; } //显示下一菜单 } echo "</table>"; } ?> <br /> <br /> <?php if ($tpye=="add") { ?> <table width="551" border="0" cellpadding="0" cellspacing="1" bgcolor="#cccccc"> <form action="" method="post" name="form1"> <tr> <td height="28" colspan="2" align="center" bgcolor="#ffffff">添加栏目</td> </tr> <tr> <td width="246" height="28" align="right" bgcolor="#ffffff">栏目名称:</td> <td width="302" height="28" bgcolor="#ffffff"><input name="name" type="text" id="name" /></td> </tr> <tr> <td height="28" align="right" bgcolor="#ffffff">所属分类:</td> <td height="28" bgcolor="#ffffff"><select name="bid"> <?php $sql="select * from tvmenu"; $que=mysql_query($sql,$conn); while($rs=mysql_fetch_array($que)){ if ($rs['id']==$b) { $selected="selected="selected""; }else{ $selected=""; } ?> <option value="<?php echo $rs["id"]; ?>" <?php echo $selected;?>><?php echo $rs["name"]; ?></option> <?php }?> </select> </td> </tr> <tr> <td height="28" colspan="2" align="center" bgcolor="#ffffff"><input type="submit" name="submit" value="提 交" /></td> </tr> </form> </table> <?php }?> |
本文章要讲的php 缓存技术是讲把数据生成一个临时缓存文件保存到硬盘,然后根据缓存文件设定的时间删除缓存文件再次生成新的缓存文件哦。
代码如下 | 复制代码 |
$filename = 'cachefile.php'; //写缓存文件 function createcache($filename,$str) //读取缓存文件 function readcache($filename) |
/*
本站原创文章,转载注明来源http://www.111cn.net/phper/php.html
*/