導航:首頁 > 編程語言 > php驗證碼登陸界面

php驗證碼登陸界面

發布時間:2022-03-14 14:04:28

① 怎麼利用php製作簡單登入界面效果如下

<scripttype="text/javascript"src="jquery-1.7.2.min.js"></script>
<formaction="#"method="post"style="padding:20px"id="form1"><table><tr><td><labelfor="email">郵箱:</label></td><td><inputtype="text"name="email"id="email"value=""/></td></tr><tr><td><labelfor="password">密碼:</label></td><td><inputtype="password"name="password"id="password"/></td></tr><tr><td></td><td><inputtype="button"value="登陸"onclick="check_input()"/><inputname="on_submit"id="on_submit"type="hidden"value="0"/></td></table></form>

<scripttype="text/javascript">functioncheck_input(){
varpassword=$('#password').val();
varemail=$('#email').val();
varvalidatecode=$('#validatecode').val();

email=trim(email);
if(email==''){
alert('請輸入您的注冊郵箱!');
$('#mail').focus();
returnfalse;
}else{
vartag=checkEmail(email);
if(tag==false){
alert('請輸入正確的郵箱地址!');
$('#email').focus();
returnfalse;

}
}
password=trim(password);
if(password==''){
alert('請輸入您的密碼!');
$('#password').focus();
returnfalse;
}

validatecode=trim(validatecode);
if(validatecode==''){
alert('請輸入驗證碼!');
$('#validatecode').focus();
returnfalse;
}
$('#on_submit').val(1);
$('#form1').submit();
}

//email判斷
functioncheckEmail(cEmail)
{
vararr=cEmail.split('@');
varc=true;
if(arr.length!=2)
c=false;
elseif(!arr[0].length||!arr[1].length)
c=false;
elseif(arr[1].split('.').length<2)
c=false;
elseif(!arr[1].split('.')[0].length||arr[1].split('.')[1].length<2||arr[1].split('.')[1].length>4)
c=false;
returnc;
}
functiontrim(str){
returnrtrim(ltrim(str));
}
functionltrim(s){
returns.replace(/(^s*)/g,"");
}
//去右空格;
functionrtrim(s){
returns.replace(/(s*$)/g,"");
}
</script>

拿去改改就能用了!!

② php 登陸首次頁面載入不生成驗證碼

js點擊事件,點擊後就會生成一個IMG標簽 src屬性 是那個驗證碼的php地址

③ php中用戶登入和驗證碼驗證問題

我一般都用Zend,所以你的代碼沒有看太懂。只是淺淺的注意到裡面有一段代碼:
if (isset($_SESSION['PrevUrl']) && false) {
這里不出意外的話永遠會是false吧。
但好像問題也不再這里。讓我更沒有明白的是你的$_SESSION['yzm']是在這個腳本執行以前就被寫好的嗎?因為我在這個腳本里除了最後一個if裡面看到這個東西以外,就沒有看到了。

④ 這是我的html的登錄界面與驗證碼的生成代碼,另外PHP中怎麼驗證驗證碼的正確性。用戶和密碼的驗證已會。

將生成的驗證碼保存到session,同時輸出到表單邊上,用戶將輸出的驗證碼輸入表單,這是再將用戶輸入的驗證碼與session中保存的驗證進行比較,相等則驗證通過反之驗證失敗!!!

⑤ 這個PHP後台登陸頁面,去除驗證碼,要刪除那些代碼可以正常登陸!

將這個文件中的35-37行刪掉,可以在提交前不再提示「驗證碼不能為空」
將這個文件中的121-123行刪掉,可以不顯示驗證碼輸入框和驗證碼圖片,刪掉121-123之後為了避免js報錯,需要刪除 27行,還需要刪除47行中的 ,"verify":verify.value

然後還需要修改 第46行 U(ACTION_NAME) 這個提交文件內的代碼

⑥ 用dreamweaver製作帶驗證碼的php登陸頁面

驗證碼生成文件中,把驗證碼字元寫入會話:sesssion

登陸驗證處理文件中,獲取用戶輸入的驗證碼和這個session進行比對,對得上則正確

對不是則不正確!

你可以參考我的博客的一篇文章:

⑦ 求一個php登陸界面和圖片驗證碼(網址也可以)

index.php

<?php
session_start();
session_register('SafeCode');
?>
<SCRIPT language=javascript>
<!--
function CheckForm()
{
if(document.Login.u_name.value=="")
{
alert("請輸入用戶名!");
document.Login.u_name.focus();
return false;
}
if(document.Login.u_pass.value == "")
{
alert("請輸入密碼!");
document.Login.u_pass.focus();
return false;
}
if (document.Login.CheckCode.value==""){
alert ("請輸入您的驗證碼!");
document.Login.CheckCode.focus();
return(false);
}
}

//-->
</SCRIPT>
<script language="javascript">
var vimg_src = "../inc/code.php";
function chg_vimg()
{
var vimg = document.getElementById("vimg");
vimg.src = vimg_src + "?" + Math.random();

}
</script>
<?php
if ($deng){
if($CheckCode != $_SESSION['SafeCode'] || empty($CheckCode)){
echo "<script>alert('校驗碼不正確!');window.location.href='index.php';</script>";
exit;
}
$u_pass1=md5($u_pass);
$sql = "select * from user where name='$u_name' and pass='$u_pass1' limit 0,1";
$rs = mysql_query($sql);
while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)){
$_SESSION['u_admin_name'] = $row['u_name'];
echo "<script>window.location.href='main.php';</script>";
exit;
}
echo "<script>alert('用戶名或密碼不正確!');window.location.href='index.php';</script>";
exit;
}
?>
<TABLE cellSpacing=0 cellPadding=0 width=561 border=0>
<FORM name=Login onSubmit="return CheckForm();" action="index.php?deng=deng" method=post target=_parent>
<TBODY>

<TR>
<TD width=75 rowSpan=2>用戶登錄</TD>
<TD width=126><FONT color=#043bc9>用戶名稱:</FONT></TD>
<TD width=39 rowSpan=2></TD>
<TD width=131><FONT color=#043bc9>用戶密碼:</FONT></TD>
<TD colspan="2"><font color=#043bc9>驗證碼:</font></TD>
<TD colSpan=2 rowspan="2"><input type="submit" value="提交"></TD>
</TR>
<TR>
<TD><INPUT name=u_name></TD>
<TD><INPUT name=u_pass type=password ></TD>
<TD width="33"><input maxlength=4 size=6
name=CheckCode></TD>
<TD width=53><font color=#00cc33><a href='javascript:chg_vimg();' tabindex='-1' ><img src=code.php id=vimg title="看不清換一個!" border="0"></a></font></TD>
</TR></TBODY>
</FORM>
</TABLE>

code.php
<?
//checkNum.php
session_start();
function random($len)
{
$srcstr="abcdefghijkrmnopqrstuvwxyz"; //+0123456789
mt_srand();
$strs="";
for($i=0;$i<$len;$i++){
$strs.=$srcstr[mt_rand(0,25)];//35
}
return $strs;//strtoupper()函數轉換為大寫
}
$str=random(4); //隨機生成的字元串
$width = 40; //驗證碼圖片的寬度
$height = 17; //驗證碼圖片的高度
@header("Content-Type:image/png");
$_SESSION["SafeCode"] = $str;
//echo $str;
$im=imagecreate($width,$height);
//背景色
$back=imagecolorallocate($im,0xFF,0xFF,0xFF);
//模糊點顏色
$pix=imagecolorallocate($im,187,230,247);
//字體色
$font=imagecolorallocate($im,41,163,238);
//繪模糊作用的點
mt_srand();
for($i=0;$i<1000;$i++)
{
imagesetpixel($im,mt_rand(0,$width),mt_rand(0,$height),$pix);
}
imagestring($im, 5, 2, 0,$str, $font);
imagerectangle($im,0,0,$width-1,$height-1,$font);
imagepng($im);
imagedestroy($im);
$_SESSION["SafeCode"] = $str;
?>

⑧ 求一個php登錄代碼,有驗證碼功能,能答必採納。

<?php
Header("Content-type: image/gif");
$border = 1;
$how = 4;
$w = $how*15;
$h = 20;
$fontsize = 10;
$alpha = "abcdefghijkmnopqrstuvwxyz";
$number = "023456789";
$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<5; $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_start();
$_SESSION['randcode'] = $randcode;
Imagegif($im);
ImageDestroy($im);
?>

以上是隨機生成驗證碼的代碼,加入保存為yz.php,則使用時只需,<img src="yz.php">

<?php
session_start();
if($_SESSION['randcode'] = $_POST['yzm']){
echo '驗證碼錯誤'
exit;
}else{
$sql = "SELECT id FROM table WHERE yhm = '".$_POST['yhm']."' AND mm = '".$_POST['mm']."'";
$result = mysql_query($sql);
if($result){
echo '<meta http-equiv="refresh" content="0;url=index.html"/>'
exit;
}else{
echo '賬號或密碼錯誤'
exit;
}
}
?>

比較簡單,懂的應該都懂

⑨ 用PHP做登陸注冊頁面

登錄頁:login.php
<?php
include("conn.php");
$username=$_POST['name'];
$password=$_POST['password'];
$yanzheng=$_POST['yanzheng'];

if(isset($_POST['submit']))
{
$sql=("select username,password from member where username='$username' and password='$password'") or die("sql語句執行失敗");
//print_r($sql);
$ar=mysql_query($sql);
if($ar)
{
if($row=mysql_fetch_array($ar))
{
session_start();
if($_POST["yanzheng"])
{
if($yanzheng!=$_session[pic]||$yanzheng=="")
{
echo "驗證碼輸入有誤";
exit;
}
if($yanzheng==$_session[pic])
{
header("location:index.php");
}
}
}
else
{
echo "用戶名或密碼錯誤";
}
}
}

?>

<form action="login.php" method="post">
<table border=1 align=center width=500 height=300 bgColor=#DFFFDF bordercolor=#fffbec>
<tr>
<td colspan=2 align=center>用戶登錄</td>
</tr>
<tr>
<td>用戶姓名:</td>
<td><input type="text" name="name" id="name"/></td>
</tr>
<tr>
<td>用戶密碼:</td>
<td><input type="password" name="password" id="password"/></td>
</tr>
<tr>
<td>驗證碼:</td>
<td><input type="text" name="yanzheng" id="yanzheng"/>
<img src="yanzheng1.php" width="50" height="30"></img>
</td>
</tr>
<tr>
<td colspan=3 align=center>
<input type="submit" name="submit" value="登錄"/>
<input type="reset" name="reset" value="重置"/>
<a href="register.php">注冊</a>
</td>
</tr>
</table>
</form>

注冊頁:register.php

<?php
include("conn.php");
if(isset($_POST['submit'])&&$_POST['submit']) {
if($_POST['username']=='')
{
echo "用戶名不能為空";
exit();
}
if($_POST['password']=='')
{
echo "密碼不能為空";
exit();
}
if($_POST['realpass']!=$_POST['password'])
{
echo "兩次密碼輸入不一致";
exit();
}

$sql="insert into member(username,real_name,password,email,headimg) values('$_POST[username]','$_POST[username]','$_POST[password]','$_POST[email]','')";
$ar=mysql_query($sql);
if($ar)
{
header("location:index.php");
}
else
{
echo mysql_error();
}
}
?>
<body>
<form action="register.php" method="post">
<table border=1 align=center width=500>
<tr>
<td height=40 bgColor=#DFFFDF colspan=2>會員注冊 [<a href="login.php">返回登錄頁</a>]</td>
</tr>
<tr>
<td height=40 bgColor=#fffbec >會員ID</td>
<td><input type="text" name="username" id="username"/></td>
</tr>
<tr>
<td height=40 bgColor=#fffbec>密碼</td>
<td><input type="password" name="password" id="password"/></td>
</tr>
<tr>
<td height=40 bgColor=#fffbec>確認密碼</td>
<td>
<input type="password" name="realpass" id="realpass"/>
</td>
</tr>
<tr>
<td height=40 bgColor=#fffbec>EMAIL</td>
<td><input type="text" name="email" id="email"/>

</tr>
<tr>
<td height=40 bgColor=#fffbec></td>
<td><input type="submit" name="submit" value="注冊"/><input type="reset" value="重置"></td>
</tr>
</table>
</form>
</body>

主頁顯示:index.php
<?php
include("conn.php");
function cutstr($str,$cutleng)
{
$str = $str; //要截取的字元串
$cutleng = $cutleng; //要截取的長度
$strleng = strlen($str); //字元串長度
if($cutleng>$strleng)return $str;//字元串長度小於規定字數時,返回字元串本身
$notchinanum = 0; //初始不是漢字的字元數
for($i=0;$i<$cutleng;$i++)
{
if(ord(substr($str,$i,1))<=128)
{
$notchinanum++;
}
}
if(($cutleng%2==1)&&($notchinanum%2==0)) //如果要截取奇數個字元,所要截取長度范圍內的字元必須含奇數個非漢字,否則截取的長度加一
{
$cutleng++;
}
if(($cutleng%2==0)&&($notchinanum%2==1)) //如果要截取偶數個字元,所要截取長度范圍內的字元必須含偶數個非漢字,否則截取的長度加一
{
$cutleng++;
}
return substr($str,0,$cutleng);
}
?>
<html>
<head>
<script type="text/javascript">
function All(e, itemName)
{
var aa = document.getElementsByName(itemName);
for (var i=0; i<aa.length; i++)
aa[i].checked = e.checked; //得到那個總控的復選框的選中狀態
}
function Item(e, allName)
{
var all = document.getElementsByName(allName)[0];
if(!e.checked) all.checked = false;
else
{
var aa = document.getElementsByName(e.name);
for (var i=0; i<aa.length; i++)
if(!aa[i].checked) return;
all.checked = true;
}
}
</script>
</head>
<?php
include("conn.php");
if(isset($_POST['del']))
{
$mm = $_POST["selected"];
$id =implode(",",$mm);
$sql = "delete from forums where id in(".$id.")";
//echo $sql;
$result=mysql_query($sql);
echo $result?"刪除成功":"刪除失敗";
}
?>
<table style="BORDER-BOTTOM-WIDTH: 1px; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=600 align=center border=1 bordercolor=#ddddff>
<tr align=middle>
<td height=40 bgColor=#DFFFDF colspan=3>論壇列表</td>
</tr>
<tr>
<td colspan=3><a href="login.php" style="float:right">[退出系統]</a><a href="add_forum.php" style="float:right">[添加論壇]</a></td>
<td></td>
</tr>
<tr align=middle>
<td height=40 bgColor=#DFFFDF width=80>狀態</td>
<td height=40 bgColor=#DFFFDF>論壇</td>
<td height=40 bgColor=#DFFFDF>最後更新</td>
</tr>
<?php
$sql="select * from forums";
$result=mysql_query($sql);
$num=mysql_num_rows($result);
if($num>0)
{
while($row=mysql_fetch_array($result)){
?>
<tr align=middle>
<td bgColor=#fffbec><input type="checkbox" name="selected" value="1"/></td>
<td height=50 bgColor=#fffbec width=300>
<?php
echo "<div><a href=\"forums.php?F=".$row['ID']."\">".$row['forum_name']."</a></div>";
echo cutstr($row['forum_description'],24);//最多顯示24個位元組,12個字,多餘部分用省略號代替
echo "……";
?>
</td>
<td height=50 bgColor=#fffbec><div><?php echo $row['last_post_time']."by".$row['last_post_author']?></div></td>

</tr>
<?php
}
}
else
{
echo "<tr bgColor=#fffbec><td colspan=3>對不起,論壇尚在創建中……</td></tr>";
}
?>
<tr>
<td colspan=3> <input type="checkbox" name="selected" value="1" onclick="All(this,'selected')"/>全選/不全選</td>
</tr>
<tr>
<td><input type="button" name="del" id="del" value="刪除選中項"/>
<?php

?>
</td>
</tr>
</table>
</html>

資料庫你就自己建,望採納~

閱讀全文

與php驗證碼登陸界面相關的資料

熱點內容
優信二手車解壓後過戶 瀏覽:62
Windows常用c編譯器 瀏覽:778
關於改善國家網路安全的行政命令 瀏覽:833
安卓如何下載網易荒野pc服 瀏覽:654
javainetaddress 瀏覽:104
蘋果4s固件下載完了怎麼解壓 瀏覽:1003
命令zpa 瀏覽:285
python編譯器小程序 瀏覽:944
在app上看視頻怎麼光線調暗 瀏覽:540
可以中文解壓的解壓軟體 瀏覽:593
安卓卸載組件應用怎麼安裝 瀏覽:913
使用面向對象編程的方式 瀏覽:339
程序員項目經理的年終總結範文 瀏覽:929
內衣的加密設計用來幹嘛的 瀏覽:432
淮安數據加密 瀏覽:292
魔高一丈指標源碼 瀏覽:982
松下php研究所 瀏覽:168
c回調java 瀏覽:400
夢幻端游長安地圖互通源碼 瀏覽:746
電腦本地文件如何上傳伺服器 瀏覽:313