这是关于密码表单验证和使用大写、小写、数字和字符组合的一般问题。
研究表明 preg_match 是验证密码(或您使用的任何变量)所必需的: (preg_match("/^. (?=.{8,})(?=. [0-9])(?=. [ az])(?=. [AZ]).*$/")
虽然我将如何将它整合到下面的 if 语句中?我尝试使用 && 将它们组合起来,尽管这似乎忽略了 preg_match 部分。if(($pass == $pass2) && (preg_match("/^. (?=.{8,})(?=. [0-9])(?=. [az])(?=. [ AZ]).*$/"))
任何意见,将不胜感激。
<?php
require "dbconn.php";
$username = ($_GET['username']);
$email = ($_GET['email']);
$pass = ($_GET['pwd1']);
$pass2 = ($_GET['pwd2']);
$USN = ($_GET['schoolnumber']);
$matching = 0;
if($pass == $pass2)
{
echo "<script type='text/javascript'> window.alert('Your details have been successfully registered, please proceed to login with your new credentials!')</script>";
echo '<script>javascript:window.close();</script>';
$query = "INSERT INTO customer VALUES ('".$username."','".$email."','".$pass."','face1.jpg','".$USN."','N')";
$results = mysql_query($query) or die (mysql_error());
$results1 = mysql_query($query1) or die (mysql_error());
}
else{
header('Location:register.php?matching=1');
}
?>