验证注册表问题 [英] Validation on register form problem

查看:119
本文介绍了验证注册表问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我一直在关注有关phpacademy的教程,到目前为止一切都进展顺利,但我已经开始验证注册表,并遇到了问题.

问题:当我在所有字段上测试验证时,无论是否满足密码成功条件,都会显示密码语句(如下所示).例如,如果密码是正确的字符数,但用户名不是,则显示密码IF功能的错误消息,而不显示用户名的错误消息,这意味着我无法获得显示成功!"的形式.

下面是表单的我的PHP代码:

Hi all,

Ive been following a tutorial on phpacademy and all has gone well so far but i''ve come to validating a register form and have ran into a problem.

The problem: when I test the validation on all fields the password statement (shown below) is shown regardless of whether the password success criteria is met or not. For example, if the password IS the correct amount of characters but the username IS NOT, the error message for the password IF function is displayed and not the error message for the username, meaning I cannot get the form the display "Success!".

Below is my PHP code for the form:

$submit = $_POST['submit'];
$fullname = strip_tags($_POST['fullname']);
$username = strip_tags($_POST['username']);
$emailaddress = strip_tags($_POST['emailaddress']);
$repeatemailaddress = strip_tags($_POST['repeatemailaddress']);
$password = strip_tags($_POST['password']);
$repeatpassword = strip_tags($_POST['repeatpassword']);
$date = date("Y-m-d");

if ($submit)
{	
	//check for existance
	if ($fullname&&$username&&$emailaddress&&$repeatemailaddress&&$password&&$repeatpassword)
	{
		//encrypt password
		$password = md5($password);
		$repeatpassword = md5($repeatpassword);
		
		if ($password=$repeatpassword&&$emailaddress=$repeatemailaddress)
			{
			
			//check character length of username and fullname
			if (strlen($username)>25||strlen($fullname)>25)
				{
					echo "Length of username or fullname is too long!";
				}
				else
					{
					//check email length
						if (strlen($emailaddress)>50||strlen($emailaddress)<10)
						{
							echo "Your email address must be between 10 and 50 characters!";
						}
							else
							{
							//check password length
								if (strlen($password)>25||strlen($password)<6)
								{
									echo "Your password must be between 6 and 25 characters!";
								}			
									else
								{
								//register the user	
								echo "Success!";
								}
							}
					}
				
				}
		else
			echo "Your passwords or email address do not match!";
	
	} //wnd of password/email check
else
	echo "Please fill in all fields!";
	
}

推荐答案

提交 =
submit =


_POST [' 提交'];
_POST['submit'];


全名 = strip_tags(
fullname = strip_tags(


这篇关于验证注册表问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆