一個註冊的php網站怎麼加一段驗證碼呢?
求大神指教
最簡單的四個數字那種就行
線上等啊!!!
回複討論(解決方案)
//---------驗證碼產生函數-------//public function verify_image(){//產生驗證碼圖片header("Content-type: image/png");// 全數字$str = "2,3,4,5,6,7,8,9,a,b,c,d,f,g,h,i,j,k,m,n,p,q,r,s,t,u,v,w,x,y,z"; //要顯示的字元,可自己進行增刪$list = explode(",", $str);$cmax = count($list) - 1;$verifyCode = '';for ( $i=0; $i < 5; $i++ ){$randnum = mt_rand(0, $cmax);$verifyCode .= $list[$randnum]; //取出字元,組合成為我們要的驗證碼字元}//$_SESSION['code'] = $verifyCode; //將字元放入SESSION中//$this->session->set_userdata('code', $verifyCode);$im = imagecreate(58,28); //產生圖片$black = imagecolorallocate($im, 0,0,0); //此條及以下三條為設定的顏色$white = imagecolorallocate($im, 255,255,255);$gray = imagecolorallocate($im, 200,200,200);$red = imagecolorallocate($im, 255, 0, 0);imagefill($im,0,0,$white); //給圖片填充顏色//將驗證碼繪入圖片imagestring($im, 5, 10, 8, $verifyCode, $black); //將驗證碼寫入到圖片中for($i=0;$i<50;$i++){imagesetpixel($im, rand(0,58) , rand(0,28) , $black); //加入點狀幹擾素 imagesetpixel($im,rand(0,58),rand(0,28),$red); imagesetpixel($im, rand(0,58) , rand(0,28) , $gray); //imagearc($im, rand(0,58), rand(0,28), 20, 20, 75, 170, $black); //加入弧線狀幹擾素 //imageline($im, rand(0,58), rand(0,28), rand(0,58), rand(0,28), $red); //加入線條狀幹擾素}imagepng($im);imagedestroy($im);}
請問這個是另外單開一個檔案還是直接加在原來的上面呢
---------------------------------------------------------------------------
session_start();
include("Config/Config.php");
include("ip.php");
if(!$isREG) die("帳號註冊功能已關閉,請等待開放再註冊!");
if($_POST){
//提交
include_once("Config/function_common.php");
$illegal=illegalsubmit();
if(!$illegal) die("禁止非法提交");
$POST=Addslashess($_POST);
include_once("Config/mysql_new_class.php");
$con=new mysql_class($SQLhost,$SQLuser,$SQLPWD,$DATABASE);
//帳號是否存在
$sql="select username,password from oluc_user where username='$POST[username]'";
$usr=$con->queryrow($sql);
$i = $POST['ip'];
$pass1 = rawurlencode(base64_encode($POST['password']));
$pass2 = rawurlencode(base64_encode($POST['repassword']));
if($pass1!=$pass2){
die("");
}else{
if(!$usr)
{
$sql="insert into oluc_user(UserName,PassWord,CreateTime,CreateIp) values('$POST[username]','$POST[password]',now(),'$i')";
mysql_query($sql);
$username=rawurlencode(base64_encode($POST[username]));
$password=rawurlencode(base64_encode($POST[password]));
//$url ='login.php';
//header("Location: $url");
//exit;
die("");
}else{ die("");}
}
mysql_close();
}
?>
<?php echo $Title ?>修改密碼
進入官網快速儲值" target="_blank">官方論壇" onclick="window.external.addFavorite(location.href,'');return false;" rel="sidebar" title="">收藏本頁
----------------------------------------------------------
我的是這樣的 求教!!!
驗證碼:
function create_code(){
document.getElementById('code2').src = 'verify_image';
}
大神能否直接加到我發的那裡面
完全不懂這些東西
麻煩了
感謝感謝萬分感謝!!!
你的驗證碼在哪就放哪啊
完全沒搞懂 呵呵
$code = mt_rand(1000,9999);$_SESSION['code' ] = $code;
echo $_SESSSION['code'];
看下 gd2 自己畫個吧。
其實可以自己去極驗驗證的後台下載一個他們的SDK,直接安裝好就可以使用啦,很方便的還可以查看後台資料。關鍵是安全性很高哦,還不用自己編程,滑動一下就搞定了。http://www.geetest.com/