当前位置: 编程技术>php
本页文章导读:
▪php与ajax无刷新分页的实现代码(兼容多浏览器) 无刷新分页,兼容IE与Firefox等浏览器。
1、index.php
<?php
header("Content-Type:text/html;charset=utf-8");
?>
<html>
<head>
<title>无刷新分页_www.</title>
<style>
A{text-decoration:none;}
.........
▪php点击验证码实时刷新的实现代码 具体实现如下。
1、验证码页 code.php
<?php
/**
* 验证码页
* www.
*/
Header("Content-type: image/gif");
/*
* 初始化
*/
$border = 0; //是否要边框 1要:0不要
$how = 4; //验证码位数
$w.........
▪php iframe无刷新上传文件的实现代码 有关iframe的内容,可以参考:html的iframe标签对象详解。
代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xht.........
[1]php与ajax无刷新分页的实现代码(兼容多浏览器)
来源: 互联网 发布时间: 2013-12-24
无刷新分页,兼容IE与Firefox等浏览器。
1、index.php
<?php
header("Content-Type:text/html;charset=utf-8");
?>
<html>
<head>
<title>无刷新分页_www.</title>
<style>
A{text-decoration:none;}
A:link {COLOR:#33CCFF;}
A:active {COLOR:#FF6666;}
A:visited {COLOR:#33CCFF;}
A:hover {COLOR:#FF6699; TEXT-DECORATION: underline;position:relative;left:1px;top:1px}
</style>
<script src="/blog_article/jquery-1.5.1.js"></script>
<script language="javascript">
$(document).ready(function(){
changepage(1);
});
function changepage(page){
$.post("sql.php",{page:page},function(data){
$("#test").html(data);
});
}
</script>
</head>
<body>
<ul id="test"></ul>
</body>
</html>
2、sql.php
<?php
mysql_connect()("","root","");
mysql_select_db("test");
mysql_query()("set names utf8");
if(isset()($_POST["page"])){
@$page = max(1, intval($_POST["page"]));
$pagesize=10;
$startindex=($page-1)*$pagesize;
$sql="SELECT * FROM test ORDER BY id LIMIT $startindex,$pagesize";
$rec=mysql_query($sql);
while($row=mysql_fetch_array($rec)){
$str.="<li>".$row["uname"]."</li>";
}
$num=mysql_num_rows(mysql_query("select * from test"));
$pagenum=@ceil($num/$pagesize);
for($i=1;$i<=$pagenum;$i++){
if($page==$i){
$str.="<a href='javascript:void(0)' onclick=changepage(".$i.")>[".$i."]</a> ";
}else{
$str.="<a href='javascript:void(0)' onclick=changepage(".$i.")>".$i."</a> ";
}
}
echo $str;
}else{
die();
}
?>
3、test数据库 test表
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for test
-- ----------------------------
DROP TABLE IF EXISTS `test`;
CREATE TABLE `test` (
`id` int(10) NOT NULL auto_increment,
`uname` char(50) character set utf8 NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=gb2312 COLLATE=gb2312_bin;
-- ----------------------------
-- Records
-- ----------------------------
INSERT INTO `test` VALUES ('1', 'aaaaaaaaaaa');
INSERT INTO `test` VALUES ('2', 'bbbbbbbbbbbb');
INSERT INTO `test` VALUES ('3', 'cccccccccccc');
INSERT INTO `test` VALUES ('4', 'dddddddddddddddd');
INSERT INTO `test` VALUES ('5', 'eeeeeeeeeee');
INSERT INTO `test` VALUES ('6', 'ffffffffff');
INSERT INTO `test` VALUES ('7', 'ggggggggggggggg');
INSERT INTO `test` VALUES ('8', 'hhhhhhhhhhhh');
INSERT INTO `test` VALUES ('9', 'jjjjjjjjjjjjjjjj');
INSERT INTO `test` VALUES ('10', 'kkkkkkkkkkk');
INSERT INTO `test` VALUES ('11', 'mmmmmmmmmmm');
INSERT INTO `test` VALUES ('12', 'cccccccccccccccccc');
INSERT INTO `test` VALUES ('13', 'bbbbbbbbbbbb');
INSERT INTO `test` VALUES ('14', 'ooooooooooooooooo');
INSERT INTO `test` VALUES ('15', 'pppppppppppp');
INSERT INTO `test` VALUES ('16', 'aaaaaaaaaaaaaaa');
INSERT INTO `test` VALUES ('17', 'ggggggggggggggggg');
INSERT INTO `test` VALUES ('18', 'dddddddddddddddd');
INSERT INTO `test` VALUES ('19', 'cccccccccccccc');
INSERT INTO `test` VALUES ('20', 'xxxxxxxxxx');
INSERT INTO `test` VALUES ('21', 'zzzzzzzzzzzzzzz');
INSERT INTO `test` VALUES ('22', 'oooooooooooooooooooo');
INSERT INTO `test` VALUES ('23', 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii');
INSERT INTO `test` VALUES ('24', 'uuuuuuuuuuuuuuuuuuuuuuuuuuuuu');
INSERT INTO `test` VALUES ('25', 'yyyyyyyyyyyyyyyyyy');
INSERT INTO `test` VALUES ('26', 'ttttttttttttttttttttttttttt');
INSERT INTO `test` VALUES ('27', 'rrrrrrrrrrrrrrrrrrrrrrrr');
INSERT INTO `test` VALUES ('28', 'eeeeeeeeeeeeeeeeeeeee');
INSERT INTO `test` VALUES ('29', 'wwwwwwwwwwwwwwwwwwwww');
INSERT INTO `test` VALUES ('30', 'qqqqqqqqqqqqq');
[2]php点击验证码实时刷新的实现代码
来源: 互联网 发布时间: 2013-12-24
具体实现如下。
1、验证码页 code.php
<?php
/**
* 验证码页
* www.
*/
Header("Content-type: image/gif");
/*
* 初始化
*/
$border = 0; //是否要边框 1要:0不要
$how = 4; //验证码位数
$w = $how*15; //图片宽度
$h = 20; //图片高度
$fontsize = 6; //字体大小
$alpha = "abcdefghjkmnpqrstuvwxyz"; //验证码内容1:字母
$number = "23456789"; //验证码内容2:数字
$randcode = ""; //验证码字符串初始化
srand((double)microtime()*1000000); //初始化随机数种子
$im = ImageCreate($w, $h); //创建验证图片
/*
* 绘制基本框架
*/
$bgcolor = ImageColorAllocate($im, 255, 255, 255); //设置背景颜色
ImageFill($im, 0, 0, $bgcolor); //填充背景色
if($border)
{
$black = ImageColorAllocate($im, 0, 0, 0); //设置边框颜色
ImageRectangle($im, 0, 0, $w-1, $h-1, $black);//绘制边框
}
/*
* 逐位产生随机字符
*/
for($i=0; $i<$how; $i++)
{
$alpha_or_number = mt_rand(0, 1); //字母还是数字
$str = $alpha_or_number ? $alpha : $number;
$which = mt_rand(0, strlen($str)-1); //取哪个字符
$code = substr($str, $which, 1); //取字符
$j = !$i ? 4 : $j+15; //绘字符位置
$color3 = ImageColorAllocate($im, mt_rand(0,100), mt_rand(0,100), mt_rand(0,100)); //字符随即颜色
ImageChar($im, $fontsize, $j, 3, $code, $color3); //绘字符
$randcode .= $code; //逐位加入验证码字符串
}
/*
* 添加干扰
*/
for($i=0; $i<10; $i++)//绘背景干扰线
{
$color1 = ImageColorAllocate($im, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255)); //干扰线颜色
ImageArc($im, mt_rand(-5,$w), mt_rand(-5,$h), mt_rand(20,300), mt_rand(20,200), 55, 44, $color1); //干扰线
}
/*
for($i=0; $i<$how*40; $i++)//绘背景干扰点
{
$color2 = ImageColorAllocate($im, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255)); //干扰点颜色
ImageSetPixel($im, mt_rand(0,$w), mt_rand(0,$h), $color2); //干扰点
}*/
//把验证码字符串写入session
session_start();
$_SESSION['randcode'] = $randcode;
/*绘图结束*/
Imagegif($im);
ImageDestroy($im);
/*绘图结束*/
?>
2、登录页,验证码 login.php
<?php
/*
* 登录页,测试验证码
* site www.
*/
session_start();
if($_POST[sub]){
//if(!empty($_POST[gd_pic])){
//判断验证码是否相同
if($_POST[gd_pic]==$_SESSION[randcode]){
echo "验证成功!";
}else{
echo "验证码错误";
}
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>验证码测试</title>
<script>
function formSubmit(){
document.actionForm.action = "login.php";
document.actionForm.submit();
}
</script>
</head>
<body>
<form name="actionForm" action="/blog_article/login.html" method="POST">
验证码:<input type="text" name="gd_pic"/><img src="/blog_article/code.html" onClick="this.src='code.php'"/><br>
<input type="submit" name="sub" value="submit"/>
<a href="javascript:formSubmit()" name="sub">发布</a>
</form>
</body>
</html>
您可能感兴趣的文章:php验证码简单函数代码(附效果图)
分享一个php 验证码类及调用示例
php验证码的三个实例代码分享
一个php验证码的封装类
php自定义大小验证码的实例代码
php生成扭曲及旋转的验证码图片的实例代码
php仿QQ验证码的实现代码
php验证码函数使用的例子
php5验证码类(简易实用型)
php验证码(GD库生成验证码)的例子
php图片验证码的例子
php彩色验证码的简单例子
php验证码刷新与局部刷新的实现方法
php GD库生成验证码的实例
php生成验证码的例子
php随机验证码 php生成随机验证码(图文)
一个比较稳定的php登陆系统验证码
用php生成带有雪花背景的验证码
[3]php iframe无刷新上传文件的实现代码
来源: 互联网 发布时间: 2013-12-24
有关iframe的内容,可以参考:html的iframe标签对象详解。
代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN"> <head> <meta http-equiv="Content-Language" content="zh-cn" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="robots" content="all" /> <title>Iframe无刷新上传</title> <link rel="stylesheet" type="text/css" href="/blog_article/template/style.css" /> </head> <body onload='iframe1.window.location="show_image.php"'> <div id="header">AJAX无刷新上传演示</div> <div id="des"> 只允许上传格式为jpg,gif,png的图片,大小不超过1000K,上传后的图片会放在临时文件夹<br /> 浏览器必须支持JavaScript和没有屏蔽Iframe,不然将看不到效果 </div> <div id="mainform"> <form action="/blog_article/upload.html" method="post" enctype="multipart/form-data" name="upload_img" target="iframe1"> 选择要上传的图片:<input type="file" name="image"><br /> <input type="submit" value="上传图片"> </form> </div> <div id="message" onclick="this.style.display='none'"></div> <table id="maintable"> <tr> <td colspan="2" id="title">临时文件夹中的全部图片</td> </tr> <tr> <td> <form method="post" name="delimage" action="/blog_article/del.html" target="iframe1"> <a href="#" onclick='javascript:document.delimage.submit();'>[删除所有图片]</a> </form> </td> <td> <form method="post" name="showimage" action="/blog_article/show_image.html" target="iframe1"> <a href="#" onclick="javascript:document.showimage.submit();">[刷新所有图片]</a> </form> </td> </tr> <tr> <td colspan="2"><div id="show_image"></div></td> </tr> </table> <br> <iframe name="iframe1" width="0" height="0" scrolling="no"></iframe> </body> </html>php 无刷新上传方法,更多时候是结合ajax来实现,这里给大家一个参考实例:php ajax无刷新上传图片的例子。
如果你对iframe刷新不是很了解,建议您阅读下:iframe刷新方法。
最新技术文章: