Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $username = "";
- $email = "";
- $errors = array();
- $db = mysqli_connect('localhost', 'root', 'root', 'example')
- if(isset($_POST['register'])) {
- $username = mysqli_real_escape_string($db, $_POST['username']);
- $email = mysqli_real_escape_string($db, $_POST['email']);
- $password = mysqli_real_escape_string($db, $_POST['password']);
- if(empty($username)) {
- array_push($errors, "Username is required");
- }
- if(empty($email)) {
- array_push($errors, "Email is required");
- }
- if(empty($password)) {
- array_push($errors, "Password is required");
- }
- }
- if(count($errors) == 0) {
- $pass = md5($password);
- $query = "INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$pass')";
- mysqli_query($db, $query);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement