<?php
include_once "config.php";
$fname = mysqli_real_escape_string($conn, $_POST['fname']);
$lname = mysqli_real_escape_string($conn, $_POST['lname']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$password = mysqli_real_escape_string($conn, $_POST['password']);
if(!empty($fname) && !empty($lname) && !empty($email) && !empty($password)){
// check user email valid or no
if(filter_var($email, FILTER_VALIDATE_EMAIL));{
//check email already exist or no
$sql = mysqli_query($conn, "SELECT email FROM users WHERE email = '{$email}'");
if(mysqli_num_rows($sql) > 0){
echo "$email - This email already exists!";
}else {
// check user upload file
if(isset($_FILES['image'])){
$img_name = $_FILES['image']['name'];
$tmp_name = $_FILES['image']['tmp_name'];
//explode img to get img extension
$img_explode = explode('.', $img_name);
$img_ext = end($img_explode);
$extensions = ['png', 'jpg', 'jpeg', 'gif'];
if(in_array($img_ext, $extensions) === true){
$time = time(); // this will put a time in front of the image
// so that every image will have
// a unique name
// move user uploaded img to folder
$new_img_name = $time.$img_name;
if(move_uploaded_file($tmp_name, "images/".$new_img_name)){
$status = "Active now";
$random_id = rand(time(), 10000000);
// insert user data to table
sql2 = mysqli_query($conn, "INSERT INTO users (unique_id, fname, lname, email, password, img, status);
VALUES ({$random_id}, '{$fname}', '{$lname}', '{$email}', '{$password}', '{$new_img_name}', '{$status}')");
if($sql2){
$sql3 = mysqli_query($conn, "SELECT * FROM users WHERE email = '{$email}'");
if(mysqli_num_rows($sql3) > 0){
$row = mysqli_fetch_assoc($sql3);
$_SESSION['unique_id'] = $row['unique_id'];
echo "Success!";
}
}else{
echo "Something went wrong!";
}
}
}else{
echo "Please select an image file - jpg, jpeg, png or gif!"
}
}else{
echo "Please select an image file!"
}
}
}else{
echo "$email - This is not a valid email!";
}
}else {
echo "All input fields are required!";
}
?>
我正在使用此视频作为参考制作实时聊天应用程序 - https://www.youtube.com/watch?v=VnvzxGWiK54 在 signup.php
部分我总是遇到错误怎么办?在我的第一次尝试中,我遇到了愚蠢的错误。这次我的错误较少,但我总是得到这个。请指导