整晚都在看这个,我放弃了......代码直接从 $result 到最后一行,所以有些东西失败了
错误日志中没有任何内容 死时不显示错误消息。直接进入 reg_fail.html
<?php
$host = '.......'; // Host Name
$sql_username = '......'; // Sql Username
$sql_password = '.......'; // Password
$db_name = '..............'; //Database Name
$con = mysql_connect($host, $sql_username, $sql_password)or die('Error connecting to server');
mysql_select_db( $db_name)or die('Error connecting to database');
$firstName = mysql_real_escape_string($_POST['regFirstName']);
$lastName = mysql_real_escape_string($_POST['regLastName']);
$username = mysql_real_escape_string($_POST['regUser']);
$email = mysql_real_escape_string($_POST['regEmail']);
$password = mysql_real_escape_string($_POST['regPassword']);
$password = md5($password);
$query = "SELECT * FROM user WHERE username = '$username'";
$result = mysql_query($query) or die($query."<br/><br/>".mysql_error());
if($result){
$count = mysql_num_rows($result);
if($count == 0){
try{
$query = "INSERT INTO user (username, password, first_name, last_name, email)
VALUES ('$username', '$password', '$firstName', '$lastName', '$email')";
mysql_query($query , $con);
header('location: registration_success.html');
}catch(Exception $e){
header('location: registration_fail_userTaken.html');
}
}
header('location: registration_fail_userTaken.html');
}
header('location: registration_fail.html');
?>