PHP实例:用SESSION方法实现验证码
index.php(实现输入验证码页面)代码如下: Code代码如下: <html>
<head>
<title>check code</title>
</head>
<body>
<form name=check method=post action=check.php>
<input type=hidden name=init value=1>
验证码:<input type=text name=code maxlength=4 style="width=50px;">
<!--得到验证码图片-->
<img src=image.php>
<p>
<input type=submit value="提交">
</form>
</body>
</html> image.php(验证码生成页面)代码如下: Code代码如下: <?php
session_start();
srand((double)microtime()*1000000);
$authnum=rand(1000,9999);
session_register("authnum");
header("content-type:image/png");
function creat_image( $width, $height, $authnum)
{
srand((double)microtime()*1000000);
$im = imagecreate( $width, $height);
$black = ImageColorAllocate( $im, 0,0,0);
$white = ImageColorAllocate( $im, 255,255,255);
$gray = ImageColorAllocate( $im, 200,200,200);
imagefill( $im,0,0, $gray);
//将四位整数验证码绘入图片
imag
相关文档:
java中时间戳和时间字符串之间的转换
获取当前的unix时间戳
new Date().getTime()
System.currentTimeMillis()
返回的是毫秒数,要转换long t = System.currentTimeMillis()/1000;
获取当前年月日以及时分秒
Calendar c = Calendar.getInstance();
c.get(Calendar.YEAR)) c.get(Calendar.YEAR)) c.get(C ......
在PHP开发中对比起Cookie,session 是存储在服务器端的会话,相对安全,并且不像 Cookie 那样有存储长度限制,本文简单介绍 session 的使用。
由于 Session 是以文本文件形式存储在服务器端的,所以不怕客户端修改 Session 内容。实际上在服务器端的 Session 文件,PHP 自动修改 session 文件的权限,只保留 ......
array array_diff
( array array1, array array2 [, array
...] )
array_diff()
返回一个数组,该数组包括了所有在 array1
中但是不在任何其它参数数组中的值。注意键名保留不变。
猛的一看这个方法,还以为是将两个数组中不同的返回来呢,事实上不是,返回的是在array1中的,但是不在其他数组中的。 ......
之前的程序中,在服务器 error_log 中一直有这么一个错误提示:
[19-Nov-2009 22:44:50] PHP Fatal error: Cannot break/continue 1 level in /home/filename.php on line 160
但程序还是可以继续执行下去。
经查阅资料,有这么一说法:
当不在 LOOP 或 SELECT 逻辑条件中时,请不要用 break/continue 来中 ......
PHP 发送邮件
作者:w3pop.com 翻译/整理:w3pop.com 发布:2007-04-28 修改:2007-06-17 浏览:14208 :: ::
PHP Sessions
PHP allows you to send e-mails directly from a script.
PHP允许你通过脚本直接发送e-mail。
The PHP mail() Function
PHP mail()函数
The PHP m ......