我创建了一个与SQL数据库连接的注册PHP代码。问题是当它显示消息时,当我按ok
后,它没有将我发送到标题中的url。我做了很多尝试,但无法解决问题。
<?php
include 'php/db_connect.php';
if(isset($_POST["submit"])) {
$value1 = mysqli_real_escape_string($conn,$_POST['Name']);
$value2 = mysqli_real_escape_string($conn,$_POST['Email']);
$value3 = mysqli_real_escape_string($conn,$_POST['Address']);
$value4 = mysqli_real_escape_string($conn,$_POST['Username']);
$value5 = mysqli_real_escape_string($conn,$_POST['Password']);
$value6 = mysqli_real_escape_string($conn,$_POST['Confirm_Password']);
if ($value5==$value6) {
$find_a_user = mysqli_query($conn,"SELECT * FROM users WHERE (name = '$value4')");
$number_of_users = mysqli_num_rows($find_a_user);
if ($number_of_users>=1) {
header("location:http://localhost/Music_Group/mshop10.php");
echo '<script> alert("This username is not available")</script>';
}
else {
$value5 = md5($value5);
$sql = "INSERT INTO users (username, email, dienthinsi, name, password) VALUES('$value1', '$value2', '$value3', '$value4', '$value5');";
if(!mysqli_query($conn,$sql)) {
die('Error:'.mysqli_error());
}
header("location:http://localhost/Music_Group/index.php");
echo '<script> alert("Your request is being processed.")</script>';
}
}
else {
echo '<script> alert("Password verification is not the same.")</script>';
}
mysqli_close($conn);
}
?>
运行此代码时,我收到以下消息:
Warning: Cannot modify header information - headers already sent by...