如何用PHP写图片验证码验证代码
<?phprequire_once('Connections/conn_phpsql.php');?><?phpif(!function_exists("GetSQLVa...
<?php require_once('Connections/conn_phpsql.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_conn_phpsql, $conn_phpsql);
$query_Recordset_phplogin = "SELECT * FROM u_account";
$Recordset_phplogin = mysql_query($query_Recordset_phplogin, $conn_phpsql) or die(mysql_error());
$row_Recordset_phplogin = mysql_fetch_assoc($Recordset_phplogin);
$totalRows_Recordset_phplogin = mysql_num_rows($Recordset_phplogin);
?>
<?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['name'])) {
$loginUsername=$_POST['name'];
$password=$_POST['pass'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "1.asp";
$MM_redirectLoginFailed = "2.asp";
$MM_redirecttoReferrer = false;
mysql_select_db($database_conn_phpsql, $conn_phpsql);
$LoginRS__query=sprintf("SELECT user_user, user_pass FROM u_account WHERE user_user=%s AND user_pass=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $conn_phpsql) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
//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 );
}
}
?>
<form ACTION=""id="myform" name="myform" method="POST">
<table width="250" border="1">
//登陆表单
<?php
}
mysql_free_result($Recordset_phplogin);
?>
上面代码是用用户登陆时代码,如果我要插入图片验证yanzheng.php文件后,应在代码的那个位置写验证代码,让他与用户登陆一起起到验证.
假如我的图片验证码文件yanzheng.php文件产生一个SESSINO(yzm)值,由于百度有字数限制,我就把表单代码删除了,因为导入图片验证我知道,但是我就是不知道如何去写验证码,上面的代码是用DW做的用户登,当我导入图片验证码文件,我不知道如何写验证码,让图片验证码验证能和用户登陆验证一起起作用,如果有一个错误,则无法登陆,如果全部正才可以登陆,请问这个验证码怎么写,写在什么地方,请高手帮帮忙,谢谢呀,我在此谢过了
下面的人可能没有明白我的问题,我不是要写图片验证码,我是我写出的图片验证码,不知道如何去验证输入的值与图片验证码产生的值是否一致, 展开
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_conn_phpsql, $conn_phpsql);
$query_Recordset_phplogin = "SELECT * FROM u_account";
$Recordset_phplogin = mysql_query($query_Recordset_phplogin, $conn_phpsql) or die(mysql_error());
$row_Recordset_phplogin = mysql_fetch_assoc($Recordset_phplogin);
$totalRows_Recordset_phplogin = mysql_num_rows($Recordset_phplogin);
?>
<?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['name'])) {
$loginUsername=$_POST['name'];
$password=$_POST['pass'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "1.asp";
$MM_redirectLoginFailed = "2.asp";
$MM_redirecttoReferrer = false;
mysql_select_db($database_conn_phpsql, $conn_phpsql);
$LoginRS__query=sprintf("SELECT user_user, user_pass FROM u_account WHERE user_user=%s AND user_pass=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $conn_phpsql) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
//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 );
}
}
?>
<form ACTION=""id="myform" name="myform" method="POST">
<table width="250" border="1">
//登陆表单
<?php
}
mysql_free_result($Recordset_phplogin);
?>
上面代码是用用户登陆时代码,如果我要插入图片验证yanzheng.php文件后,应在代码的那个位置写验证代码,让他与用户登陆一起起到验证.
假如我的图片验证码文件yanzheng.php文件产生一个SESSINO(yzm)值,由于百度有字数限制,我就把表单代码删除了,因为导入图片验证我知道,但是我就是不知道如何去写验证码,上面的代码是用DW做的用户登,当我导入图片验证码文件,我不知道如何写验证码,让图片验证码验证能和用户登陆验证一起起作用,如果有一个错误,则无法登陆,如果全部正才可以登陆,请问这个验证码怎么写,写在什么地方,请高手帮帮忙,谢谢呀,我在此谢过了
下面的人可能没有明白我的问题,我不是要写图片验证码,我是我写出的图片验证码,不知道如何去验证输入的值与图片验证码产生的值是否一致, 展开
2个回答
AiPPT
2024-09-19 广告
2024-09-19 广告
作为北京饼干科技有限公司的工作人员,关于AIPPT免费生成PPT的功能,我可以简要介绍如下:AIPPT是一款基于人工智能技术的PPT制作工具,它为用户提供了免费生成PPT的便捷服务。用户只需简单输入PPT的主题或内容大纲,AIPPT便能智能...
点击进入详情页
本回答由AiPPT提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询