什么都没做?甚至不显示错误代码?注册表单在同一文档中。我试过$ _POST& $ _REQUEST。这是问题所在吗?
if ( $_SERVER ['REQUEST_METHOD'] =='POST' )
{
require ($_SERVER['DOCUMENT_ROOT']. '/INCLUDES/USER_DB1%20CON.php ');
$errors = array() ;
if( empty ( $_POST[' first_name ' ] ))
{ $errors[] = 'Enter Your First Name.' ; }
else
{$fn = mysqli_real_escape_string($link, trim( $_REQUEST[ 'first_name' ] )); }
if( empty ( $_POST[ ' last_name ' ] ))
{ $errors[] = 'Enter Your Last Name.' ; }
else
{$ln = mysqli_real_escape_string($link, trim( $_REQUEST[ 'last_name' ] )) ; }
if( empty ( $_POST[' email ' ] ))
{ $errors[] = 'Enter Your Email Address.' ; }
else
{$e = mysqli_real_escape_string($link, trim( $_REQUEST[ 'email' ] )) ; }
if( empty ( $_POST[' first_name ' ] ))
{ $errors[] = 'Enter Your First Name.' ; }
else
{$fn = mysqli_real_escape_string($link, trim( $_REQUEST[ 'first_name' ] )) ; }
if( !empty ($_POST ['pass1'] ))
if ( $_POST[' pass1'] != $_POST ['pass2'] )
{ $errors [] = 'Passwords Do Not Match.' ;}
else
{$p = mysqli_real_escape_string($link, trim($_REQUEST['pass1'] )) ; }
}
else { $errors[] = 'Enter A Password.' ; }
if ( empty ($errors ))
$q = "SELECT user_id FROM users WHERE email='$e'" ;
$r = mysqli_query ( $link , $q ) ;
if ( mysqli_num_rows($r) != 0 )
{ $errors[] = ' Email Address Already Registered. <a href=" ">Log In Here</a> ' ; }
if ( empty ($errors ))
{
$q = "INSERT INTO 'users'
(first_name, last_name, email, pass, reg_date)
VALUES ('$fn','$ln','$e', SHA1('$p'), NOW() ) " ;
$r = mysqli_query ( $link, $q) ;
if ( $r )
{
echo'<h1>Registered</h1>
<p>Log In <a href=" "> Here </a></p>' ;
}
mysqli_close( $link) ;
exit() ;
}
我已经尝试了所有我能想到的东西,它可能非常简单并且盯着我。
答案 0 :(得分:0)
尝试替换此:
if ( empty ($errors ))
$q = "SELECT user_id FROM users WHERE email='$e'" ;
$r = mysqli_query ( $link , $q ) ;
if ( mysqli_num_rows($r) != 0 )
{$errors[] = ' Email Address Already Registered. <a href=" ">Log In Here</a> ' ; }
if ( empty ($errors ))
{
$q = "INSERT INTO 'users'
(first_name, last_name, email, pass, reg_date)
VALUES ('$fn','$ln','$e', SHA1('$p'), NOW() ) " ;
$r = mysqli_query ( $link, $q) ;
与
if ( empty ($errors ))
$q = "SELECT user_id FROM users WHERE email='$e'" ;
$r = mysqli_query ( $link , $q ) ;
if ( mysqli_num_rows($r) != 0 )
{ $errors[] = ' Email Address Already Registered. <a href=" ">Log In Here</a> ' ; }
else
{
mysqli_query("INSERT INTO 'users'
(first_name, last_name, email, pass, reg_date)
VALUES ('$fn','$ln','$e', SHA1('$p'), NOW() ) ") ;
}