如果不使用 php,我想比较两个密码以确保它们匹配并重定向。我已经编写了这段代码,但是即使密码不匹配,if 语句中的代码也不会执行。
<?php
include 'includes/dbcnx.php';
$username = $_POST['username'];
$password = $_POST['password'];
$pass2 = $_POST['pass2'];
$email = $_POST['email'];
if($password != $pass2)
header('Location: register_form.php');
if(strlen($username)>30)
header('Location: register_form.php?error=1&usrlen=1');
$username = mysql_real_escape_string($username);
$email = mysql_real_escape_string($email);
$salt = createSalt();
$hash = hash('sha256',$salt.$hash);
mysql_select_db("sealion");
$query = "INSERT INTO users (username, password, salt, email)
VALUES ('$username','$hash','$salt','$email');";
mysql_query($query);
header('Location: index.php');
?>