菜鸟求教,如何将验证码的验证跟帐号密码加到一块去
求救啊附上源码
<?php require_once('Connections/kangci.php'); ?><?php$maxRows_a = 10;$pageNum_a = 0;if (isset($_GET['pageNum_a'])) { $pageNum_a = $_GET['pageNum_a'];}$startRow_a = $pageNum_a * $maxRows_a;mysql_select_db($database_kangci, $kangci);$query_a = "SELECT * FROM zhanghao";$query_limit_a = sprintf("%s LIMIT %d, %d", $query_a, $startRow_a, $maxRows_a);$a = mysql_query($query_limit_a, $kangci) or die(mysql_error());$row_a = mysql_fetch_assoc($a);if (isset($_GET['totalRows_a'])) { $totalRows_a = $_GET['totalRows_a'];} else { $all_a = mysql_query($query_a); $totalRows_a = mysql_num_rows($all_a);}$totalPages_a = ceil($totalRows_a/$maxRows_a)-1;$queryString_a = "";if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_a") == false && stristr($param, "totalRows_a") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_a = "&" . htmlentities(implode("&", $newParams)); }}$queryString_a = sprintf("&totalRows_a=%d%s", $totalRows_a, $queryString_a);?><?php// *** Validate request to login to this site.if (!isset($_SESSION)) { session_start();}$loginFormAction = $_SERVER['PHP_SELF'];if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck'];}if (isset($_POST['test'])) { $loginUsername=$_POST['test']; $password=$_POST['textfield']; $MM_fldUserAuthorization = "jibie"; $MM_redirectLoginSuccess = ""; $MM_redirectLoginFailed = "chatu2.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_kangci, $kangci); $LoginRS__query=sprintf("SELECT name, password, jibie FROM zhanghao WHERE name='%s' AND password=md5('%s')", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query, $kangci) or die(mysql_error()); $array=mysql_fetch_array($LoginRS); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = mysql_result($LoginRS,0,'jibie'); switch($array['jibie']){ case 1: $MM_redirectLoginSuccess = "chatu2.php?recordID=$loginUsername"; break; case 2: $MM_redirectLoginSuccess = "321.php?recordID=$loginUsername"; break; case 3: $MM_redirectLoginSuccess = "Location.php?recordID=$loginUsername"; break; } //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); }}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>动态案例站</title><style type="text/css"><!--body { background-image: url(7981635_091456690000_2.jpg); background-repeat: no-repeat;}--></style></head><body><table width="100%" height="79%" border="0"> <tr> <td height="140"> </td> </tr></table><div align="center"><table width="300" height="150" border="0"><tr><td><form ACTION="<?php echo $loginFormAction; ?>" id="form1" name="form1" method="POST"> <p> 帐号:<input name="test" type="text" /></p> <p> <label> 密码:<input type="password" name="textfield" /> </label> </p> <p><script>function changeid(id){ document.getElementById(id).src ='yzm.php?'+Math.random(1); } </script>验证码<Input type="text" name="yz" id="yz" size="8" /> <Img title="看不清,换一张" id="pc" onclick="changeid('pc')" /> <label> <input type="submit" name="Submit" value="登入" /> </label> </p></form></tr></table></div><br></body></html><?phpmysql_free_result($a);?>
下面这一块是验证码……
<?phpsession_start();$nmsg="";for($i=0;$i<4;$i++){ $nmsg.=dechex(mt_rand(0,15));} $_SESSION["code"]=$nmsg;header("Content-Type:image/jpeg");$width=75;$height=25;$img=imagecreatetruecolor($width,$height);$white=imagecolorallocate($img,255,255,255);imagefill($img,0,0,$white);$flag=false;if($flag){ $black=imagecolorallocate($img,0,0,0); imagerectangle($img,0,0,$width-1,$height-1,$black);}for($j=0;$j<6;$j++){ $randcolor=imagecolorallocate($img,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255)); imageline($img,mt_rand(0,$width),mt_rand(0,$height),mt_rand(0,$width),mt_rand(0,$height),$randcolor);}for($k=0;$k<100;$k++){ $rc=imagecolorallocate($img,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255)); imagestring($img,1,mt_rand(1,$width),mt_rand(1,$height),"*",$rc);}for($s=0;$s<strlen($nmsg);$s++){ $randcolor=imagecolorallocate($img,mt_rand(0,100),mt_rand(0,150),mt_rand(0,200)); imagestring($img,mt_rand(3,5),$s*$width/strlen($nmsg)+mt_rand(1,10),mt_rand(1,$height/2),$nmsg[$s],$randcolor);}imagejpeg($img);imagedestroy($img);?>
回复讨论(解决方案)
提交后检查验证码和$_SESSION["code"]是否对应就是了
if($_post['yz'])==$_session['code'])
可以,不过$_post 应为 $_POST, $_session 应为 $_SESSION
报错了…………
既然报错就把错误信息贴出来
if($_POST['yz'] == $_SESSION['code'])
<?phpif (!isset($_SESSION)) { session_start();}$loginFormAction = $_SERVER['PHP_SELF'];if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck'];}if (isset($_POST['test'])) { $loginUsername=$_POST['test']; $password=$_POST['textfield']; $MM_fldUserAuthorization = "jibie"; $MM_redirectLoginSuccess = ""; $MM_redirectLoginFailed = "chatu2.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_kangci, $kangci); $LoginRS__query=sprintf("SELECT name, password, jibie FROM zhanghao WHERE name='%s' AND password=md5('%s')", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query, $kangci) or die(mysql_error()); $array=mysql_fetch_array($LoginRS); $loginFoundUser = mysql_num_rows($LoginRS); if($_POST['yz'] == $_SESSION['code']) { if ($loginFoundUser) { $loginStrGroup = mysql_result($LoginRS,0,'jibie'); switch($array['jibie']){ case 1: $MM_redirectLoginSuccess = "chatu2.php?recordID=$loginUsername"; break; case 2: $MM_redirectLoginSuccess = "321.php?recordID=$loginUsername"; break; case 3: $MM_redirectLoginSuccess = "Location.php?recordID=$loginUsername"; break; } //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } } else { header("Location: ". $MM_redirectLoginFailed ); }}?>
报的错是直接说我加的这行代码错误- -
另再求问下大大……做会员模块的话数据库的设计思路……如何实现一个帐号只允许一个IP登陆啊

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

长URL(通常用关键字和跟踪参数都混乱)可以阻止访问者。 URL缩短脚本提供了解决方案,创建了简洁的链接,非常适合社交媒体和其他平台。 这些脚本对于单个网站很有价值

Laravel使用其直观的闪存方法简化了处理临时会话数据。这非常适合在您的应用程序中显示简短的消息,警报或通知。 默认情况下,数据仅针对后续请求: $请求 -

这是有关用Laravel后端构建React应用程序的系列的第二个也是最后一部分。在该系列的第一部分中,我们使用Laravel为基本的产品上市应用程序创建了一个RESTFUL API。在本教程中,我们将成为开发人员

Laravel 提供简洁的 HTTP 响应模拟语法,简化了 HTTP 交互测试。这种方法显着减少了代码冗余,同时使您的测试模拟更直观。 基本实现提供了多种响应类型快捷方式: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

PHP客户端URL(curl)扩展是开发人员的强大工具,可以与远程服务器和REST API无缝交互。通过利用Libcurl(备受尊敬的多协议文件传输库),PHP curl促进了有效的执行

您是否想为客户最紧迫的问题提供实时的即时解决方案? 实时聊天使您可以与客户进行实时对话,并立即解决他们的问题。它允许您为您的自定义提供更快的服务

2025年的PHP景观调查调查了当前的PHP发展趋势。 它探讨了框架用法,部署方法和挑战,旨在为开发人员和企业提供见解。 该调查预计现代PHP Versio的增长

在本文中,我们将在Laravel Web框架中探索通知系统。 Laravel中的通知系统使您可以通过不同渠道向用户发送通知。今天,我们将讨论您如何发送通知OV
