Exemple #1
0
                    $Query = "INSERT INTO users (first_name, last_name, password, email , avatar) VALUES ('" . $first_name . "', '" . $last_name . "', '" . $password . "', '" . $email . "','" . $target_file . "')";
                    if (mysql_query($Query)) {
                        if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
                            echo "The file " . basename($_FILES["fileToUpload"]["name"]) . " has been uploaded.";
                        } else {
                            echo "Sorry, there was an error uploading your file.";
                        }
                        echo "<h1>You have been registered successfully!</h1>";
                        header('location: home.php');
                    } else {
                        echo "<h1>Sorry the email you've entered already exists!</h1>";
                    }
                } else {
                    echo "<h1>Cannot connect to the Database!!</h1>";
                }
            } else {
                if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                    echo "<h1>Invalid E-mail, please enter a valid one.</h1><br>";
                } elseif ($password != $password_confirmation) {
                    echo "<h1>Passwords did not match, please try again.</h1><br>";
                } elseif (strlen($password) < 8) {
                    echo "<h1>The Password must be at least 8 characters";
                }
            }
        }
        echo $form;
    }
}
$Register = new Register();
$Register->regist();