当前位置: 编程技术>php
本页文章导读:
▪在PHP3中实现SESSION的功能(三)
示例程序:test_session.php3 <?php require( "session.inc.php3"); require("cookie.inc.php3"); ?> <?php session_checkid( 20 ); //20分钟后session失效 //下面你需要设置mysql的连接参数 mysql_connect('localhost','user','pass').........
▪在PHP3中实现SESSION的功能(二)
COOKIE函数库:cookie.inc.php3 <?php if (!isset($__cookie_inc__)){ $__cookie_inc__=1; function JsSetCookie($CName,$CValue,$CExpr=FALSE){ // 这个函数允许你在HTML头标记之后设置cookie , // 可以作SetCookie函数的补充,甚.........
▪PHP实现网上点歌(二)
midif2.php <? $d=dir("./dir"); //得到dir目录对象 $i="0"; while($entry=$d->read()){ $i=$i+1; if($i>2){ //大于2的目的是去掉当前目录的".",和表示前一个目录的".." $wq[]=$entry; .........
[1]在PHP3中实现SESSION的功能(三)
来源: 互联网 发布时间: 2013-11-30
示例程序:test_session.php3
<?php require( "session.inc.php3");
require("cookie.inc.php3");
?>
<?php
session_checkid( 20 ); //20分钟后session失效
//下面你需要设置mysql的连接参数
mysql_connect('localhost','user','pass') or Die("can't connect to db!");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Session/Cookie-测试</title>
</head>
<body>
<h2>This Page should show how to handle the "session.inc.php3" library</h2>
<h3>We will use a mask with a record showing routine</h3>
<?php
if( $show ) {
if( session_read() ) {
$username = $session[username];
$userpass = $session[userpass];
echo "<P>session[username]:$username
session[userpass]:$userpass";
}
}
else{
$session[username]="yourid";
$session[userpass]="12345";
if( !session_write() ) {
print $sess_error;
}else{
echo "<p>session[username]被设置成:$session[username]
" ;
echo "session[userpass]被设置成:$session[userpass]
" ;
echo "<a href='/blog_article/$PATH_INFO/show/1.html'>测试一下SESSION的作用</a>" ;
}
}
?>
</body>
</html>
原作者:不详
<?php require( "session.inc.php3");
require("cookie.inc.php3");
?>
<?php
session_checkid( 20 ); //20分钟后session失效
//下面你需要设置mysql的连接参数
mysql_connect('localhost','user','pass') or Die("can't connect to db!");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Session/Cookie-测试</title>
</head>
<body>
<h2>This Page should show how to handle the "session.inc.php3" library</h2>
<h3>We will use a mask with a record showing routine</h3>
<?php
if( $show ) {
if( session_read() ) {
$username = $session[username];
$userpass = $session[userpass];
echo "<P>session[username]:$username
session[userpass]:$userpass";
}
}
else{
$session[username]="yourid";
$session[userpass]="12345";
if( !session_write() ) {
print $sess_error;
}else{
echo "<p>session[username]被设置成:$session[username]
" ;
echo "session[userpass]被设置成:$session[userpass]
" ;
echo "<a href='/blog_article/$PATH_INFO/show/1.html'>测试一下SESSION的作用</a>" ;
}
}
?>
</body>
</html>
原作者:不详
[2]在PHP3中实现SESSION的功能(二)
来源: 互联网 发布时间: 2013-11-30
COOKIE函数库:cookie.inc.php3
<?php
if (!isset($__cookie_inc__)){
$__cookie_inc__=1;
function JsSetCookie($CName,$CValue,$CExpr=FALSE){
// 这个函数允许你在HTML头标记之后设置cookie ,
// 可以作SetCookie函数的补充,甚至代替。
// $CName.....: cookie 的名字
// $CValue....: cookie 的值
// $CEXpr.....: cookie 的有效期,以分钟为单位,也可以修改加入小时,天数
if($CExpr > 0){
$CookieString="astr= '$CName' + '=' + '$CValue' + ';expires=' + expr + ';path=/';";
$Cookie.="n<script language="javascript">n";
$Cookie.='function makeYearExpDate(min){
var expire = new Date();
expire.setTime(expire.getTime() + ((min * 60) * 1000));
expire = expire.toGMTString()
return expire
}
expr =makeYearExpDate('.$CExpr.');';
$Cookie.="n".$CookieString."n";
$Cookie.="document.cookie=astr;n</script>n";
}else{
$Cookie.="n<script language="javascript">n";
$Cookie.="document.cookie='$CName=$CValue;path=/';";
$Cookie.="n</script>n";
}
echo $Cookie;
}
}
?>
原作者:不详
<?php
if (!isset($__cookie_inc__)){
$__cookie_inc__=1;
function JsSetCookie($CName,$CValue,$CExpr=FALSE){
// 这个函数允许你在HTML头标记之后设置cookie ,
// 可以作SetCookie函数的补充,甚至代替。
// $CName.....: cookie 的名字
// $CValue....: cookie 的值
// $CEXpr.....: cookie 的有效期,以分钟为单位,也可以修改加入小时,天数
if($CExpr > 0){
$CookieString="astr= '$CName' + '=' + '$CValue' + ';expires=' + expr + ';path=/';";
$Cookie.="n<script language="javascript">n";
$Cookie.='function makeYearExpDate(min){
var expire = new Date();
expire.setTime(expire.getTime() + ((min * 60) * 1000));
expire = expire.toGMTString()
return expire
}
expr =makeYearExpDate('.$CExpr.');';
$Cookie.="n".$CookieString."n";
$Cookie.="document.cookie=astr;n</script>n";
}else{
$Cookie.="n<script language="javascript">n";
$Cookie.="document.cookie='$CName=$CValue;path=/';";
$Cookie.="n</script>n";
}
echo $Cookie;
}
}
?>
原作者:不详
[3]PHP实现网上点歌(二)
来源: 互联网 发布时间: 2013-11-30
midif2.php
<?
$d=dir("./dir"); //得到dir目录对象
$i="0";
while($entry=$d->read()){
$i=$i+1;
if($i>2){ //大于2的目的是去掉当前目录的".",和表示前一个目录的".."
$wq[]=$entry; //把目录明细放入$wq数组中
}
}
$d->close(); //关闭
?>
<html>
<head>
<title>List</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script LANGUAGE="javascript">
<!--
var onecount;
onecount=0;
subcat = new Array();
<?
$onecount="0";
for($j=0;$j<count($wq);$j++){
$dir="./dir/".$wq[$j];
$d=dir($dir); //得到每一个dir目录下的每一个目录对象
$i="0";
while($entry=$d->read()){
$i=$i+1;
if($i>2){
?>
subcat[<?echo $onecount;?>] = new Array("<?echo $entry;?>","<?echo $wq[$j];?>","<?echo $entry;?>");
<?
$onecount=$onecount+1;
}
}
$d->close();
}
?>
onecount=<?echo $onecount;?>;
function changelocation(locationid)
{
document.myform.song.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.song.options[document.myform.song.length] = new Option(subcat[i][0],subcat[i][2]);
}
}
}
//-->
</script>
</head>
<body>
<form method="post" action="/blog_article/midif1.html" name="myform" target="f1">
<select name="zj" onChange="changelocation(document.myform.zj.options[document.myform.zj.selectedIndex].value)">
<?for($i=0;$i<count($wq);$i++){?>
<option value="<?echo $wq[$i];?>"><?echo $wq[$i];?></option>
<?}?>
</select>
<select name="song">
<option selected value=""></option>
</select>
<input type="submit" name="play" value="播放">
<input type="button" name="stop" value="停止" onclick="javascript:parent.f1.location.href='/blog_article/midif1.html'">
<br>
<br>
播放次数:
<select name="looptime">
<option value="1" selected>只听一遍</option>
<option value="infinite">百听不厌</option>
</select>
<a href="javascript:history.go(0)">刷新曲目</a>
</form>
<script LANGUAGE="javascript">
<!--
changelocation(document.myform.zj.options[document.myform.zj.selectedIndex].value);
//-->
</script>
</body>
</html>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
<?
$d=dir("./dir"); //得到dir目录对象
$i="0";
while($entry=$d->read()){
$i=$i+1;
if($i>2){ //大于2的目的是去掉当前目录的".",和表示前一个目录的".."
$wq[]=$entry; //把目录明细放入$wq数组中
}
}
$d->close(); //关闭
?>
<html>
<head>
<title>List</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script LANGUAGE="javascript">
<!--
var onecount;
onecount=0;
subcat = new Array();
<?
$onecount="0";
for($j=0;$j<count($wq);$j++){
$dir="./dir/".$wq[$j];
$d=dir($dir); //得到每一个dir目录下的每一个目录对象
$i="0";
while($entry=$d->read()){
$i=$i+1;
if($i>2){
?>
subcat[<?echo $onecount;?>] = new Array("<?echo $entry;?>","<?echo $wq[$j];?>","<?echo $entry;?>");
<?
$onecount=$onecount+1;
}
}
$d->close();
}
?>
onecount=<?echo $onecount;?>;
function changelocation(locationid)
{
document.myform.song.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.song.options[document.myform.song.length] = new Option(subcat[i][0],subcat[i][2]);
}
}
}
//-->
</script>
</head>
<body>
<form method="post" action="/blog_article/midif1.html" name="myform" target="f1">
<select name="zj" onChange="changelocation(document.myform.zj.options[document.myform.zj.selectedIndex].value)">
<?for($i=0;$i<count($wq);$i++){?>
<option value="<?echo $wq[$i];?>"><?echo $wq[$i];?></option>
<?}?>
</select>
<select name="song">
<option selected value=""></option>
</select>
<input type="submit" name="play" value="播放">
<input type="button" name="stop" value="停止" onclick="javascript:parent.f1.location.href='/blog_article/midif1.html'">
<br>
<br>
播放次数:
<select name="looptime">
<option value="1" selected>只听一遍</option>
<option value="infinite">百听不厌</option>
</select>
<a href="javascript:history.go(0)">刷新曲目</a>
</form>
<script LANGUAGE="javascript">
<!--
changelocation(document.myform.zj.options[document.myform.zj.selectedIndex].value);
//-->
</script>
</body>
</html>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
最新技术文章: