首页 > 编程知识 正文

带刷新的验证码php,免费验证码什么时候刷新

时间:2023-12-28 11:57:11 阅读:328431 作者:LJGN

本文目录一览:

PHP注册关于刷新验证码的问题

验证码的作用是防止机器人频繁提交

本身就是不被建议的一种体验方式 而你这种使用随机数字来作为验证码的

根本对机器人一点防范都没有 而且也根本不存在看不清的效果

实际验证码一般都是图片 php使用示例

img id="verifyImg" src="verify.php?uid=xxxxx" /span onclick="chgVerify()"/span

verify.php 这个是php生成图片的页面

uid=xxxxx 这个是随机字符串 防止缓存导致图片不发生改变

chgVerify() js函数

chgVerify()

{

document.getElementById('verifyImg').src='verify.php?uid='+Math.random();

}

验证码是把双刃剑 用之前先考虑是否非得要用

php点击刷新验证码

第二个 onclick 事件写的不对。真确写法如下

a href="#" onclick="document.getElementById('code').src='code.php?tm='+Math.random()"看不清楚,刷新/a

你貌似没搞清楚 js 里面的this 到底是什么,所简单点 this 写在哪个标签里,指的就是那个标签。

PHP验证码 实现点击刷新

随机产生的验证码放在一个文件1中

在另一个文件中引用文件1

img src="code.php" onClick="this.src='code.php?nocache='+Math.random()" style="cursor:hand" alt="点击换一张"/

实现点击图片自动刷新图片

thinkphp验证码怎么点击刷新

HTML代码如下:

span

input type="text" name="code" placeholder="验证码" style="width:155px;height:35px;"///验证码输入框

img id="code" src="__CONTROLLER__/verify" width="128" height="35"///验证码显示图片

/span

JS控制点击刷新代码如下:

方法一:

!--验证码SRC点击随机生成--

script type="text/javascript" charset="utf-8"

var code = document.getElementById("code");

code.onclick = function(){

this.src = this.src+'?'+Math.random();

}

/script

方法二(推荐使用此方法,简洁):

img id="code" src="__CONTROLLER__/verify" width="128" height="35" onClick="this.src=this.src+'?'+Math.random()"///验证码显示图片

php中如何刷新验证码

我做的一个简单的登录界面有刷新验证码还有注册功能 希望对LZ有帮助

这个是登录界面 land.php

?php

@include_once('global.php');

session_start();

$user = $_POST['username'];

$sql = sprintf("select * from `p_admin` where `username` = '%s'",$user);

//echo $sql;

$query = $db-query($sql);//调用golbal里面的$db类

$fetch = $db-fetch_array($query);

if($_POST['sccode']==$_SESSION['rand']){

$state = $fetch ? md5($_POST['password'].$extra)==$fetch['password']:FALSE;//是否登录成功 如果失败了返回为空echo $state没有结果

if(!$state)

echo"script language=javascriptalert('用户名或密码错误');/script";

else {

$_SESSION['id'] = $fetch['m_id'];

$_SESSION['shell'] = md5($fetch['username'].$fetch['password']);

$_SESSION['ontime'] = time();

//echo $_SESSION['id']."br";

//echo $_SESSION['shell'];

$action = new action();

$action -get_show_msg('admin/admin_main.php', $show = '操作已成功!');

}

}else

echo "script language=javascriptalert('验证码错误');/script";

?

!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""

html xmlns=""head

meta http-equiv="Content-Type" content="text/html; charset=GB2312"

title用户登录/title

link href="style/global.css" rel="stylesheet" type="text/css"

link href="style/link.css" rel="stylesheet" type="text/css"

link href="style/layoutid.css" rel="stylesheet" type="text/css"

script language="javascript"

function chform (obj) {

if (obj.username.value == "") {

alert("请输入用户名!");

obj.username.focus();

return false;

}

if (obj.password.value == "") {

alert("请输入密码!");

obj.password.focus();

return false;

}

if (obj.sccode.value == "") {

alert("请输入验证码!");

obj.sccode.focus();

return false;

}

return true;

}

function RefreshImage(id)

{

document.getElementById(id).src ='Confirm.php?'+Math.random(1);

}

/script

/headbody

!--用户登录开始--

div class="login"

form id="form1" name="form1" method="post" action="" onsubmit="return chform(this)"

ul

li class="loginbtbj fright" style="background-image: url("images/hydl.gif");"a title="" href="javascript:%20close();"img src="images/close.gif" alt="关闭" align="right" border="0" height="18" width="18"/a/li

li class="fyellowxx fcenter"

.............................................................................................................

/li

li class="padleft43"

用户名:input name="username" size="15" style="width: 150px;" type="text"

/li

li class="padleft43"

密  码:input name="password" size="15" style="width: 150px;" type="password"

/li

li class="padleft43"

验证码:input name="sccode" size="6" style="width: 50px;" type="text"img id="re_confirm" onclick="RefreshImage('re_confirm')" src="Confirm.php"

a title="看不清?" href="#" onclick="RefreshImage('re_confirm')"看不清?/a a href=register.php 注册/a

/li

li class="fyellowxx fcenter"

.............................................................................................................

br

input name="Submit" src="images/dl.gif" style="border: 0pt none; width: 80px; height: 31px;" type="image"

/li

/ul

/form

/div

!--用户登录结束--

/body/html

这个是验证码的程序 confirm.php 图片什么的代码我就不穿了 LZ可以借鉴下 有一点需要注意 就是这个confirm文件里面不能报错 我在这卡了很久

因为header这个之前不能输出文本 所以如果报错 就会无法显示验证码

?php

session_start();

$random='';

for($i=1;$i5;$i++){

$random .= dechex(rand(1,15));}

$_SESSION['rand']=$random;

$im = imagecreatetruecolor(40,20);

$bg = imagecolorallocate($im,0,0,0);

$te = imagecolorallocate($im,255,255,255);

imagestring($im,rand(1,6),rand(1,6),rand(1,6),$random,$te);

header("Content-type: image/jpeg");

imagejpeg($im);

?

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。