diff --git a/assets/profile_pics/defaults/head_alizarin.png b/assets/profile_pics/defaults/head_alizarin.png new file mode 100644 index 0000000..f2caca7 Binary files /dev/null and b/assets/profile_pics/defaults/head_alizarin.png differ diff --git a/assets/profile_pics/defaults/head_amethyst.png b/assets/profile_pics/defaults/head_amethyst.png new file mode 100644 index 0000000..a1ddb0f Binary files /dev/null and b/assets/profile_pics/defaults/head_amethyst.png differ diff --git a/assets/profile_pics/defaults/head_belize_hole.png b/assets/profile_pics/defaults/head_belize_hole.png new file mode 100644 index 0000000..eeb2688 Binary files /dev/null and b/assets/profile_pics/defaults/head_belize_hole.png differ diff --git a/assets/profile_pics/defaults/head_carrot.png b/assets/profile_pics/defaults/head_carrot.png new file mode 100644 index 0000000..7e63bbf Binary files /dev/null and b/assets/profile_pics/defaults/head_carrot.png differ diff --git a/assets/profile_pics/defaults/head_deep_blue.png b/assets/profile_pics/defaults/head_deep_blue.png new file mode 100644 index 0000000..bea3aa7 Binary files /dev/null and b/assets/profile_pics/defaults/head_deep_blue.png differ diff --git a/assets/profile_pics/defaults/head_emerald.png b/assets/profile_pics/defaults/head_emerald.png new file mode 100644 index 0000000..20cc767 Binary files /dev/null and b/assets/profile_pics/defaults/head_emerald.png differ diff --git a/assets/profile_pics/defaults/head_green_sea.png b/assets/profile_pics/defaults/head_green_sea.png new file mode 100644 index 0000000..c91aa71 Binary files /dev/null and b/assets/profile_pics/defaults/head_green_sea.png differ diff --git a/assets/profile_pics/defaults/head_nephritis.png b/assets/profile_pics/defaults/head_nephritis.png new file mode 100644 index 0000000..f1c9257 Binary files /dev/null and b/assets/profile_pics/defaults/head_nephritis.png differ diff --git a/assets/profile_pics/defaults/head_pete_river.png b/assets/profile_pics/defaults/head_pete_river.png new file mode 100644 index 0000000..0894e09 Binary files /dev/null and b/assets/profile_pics/defaults/head_pete_river.png differ diff --git a/assets/profile_pics/defaults/head_pomegranate.png b/assets/profile_pics/defaults/head_pomegranate.png new file mode 100644 index 0000000..2032748 Binary files /dev/null and b/assets/profile_pics/defaults/head_pomegranate.png differ diff --git a/assets/profile_pics/defaults/head_pumpkin.png b/assets/profile_pics/defaults/head_pumpkin.png new file mode 100644 index 0000000..aa1a590 Binary files /dev/null and b/assets/profile_pics/defaults/head_pumpkin.png differ diff --git a/assets/profile_pics/defaults/head_red.png b/assets/profile_pics/defaults/head_red.png new file mode 100644 index 0000000..825168f Binary files /dev/null and b/assets/profile_pics/defaults/head_red.png differ diff --git a/assets/profile_pics/defaults/head_sun_flower.png b/assets/profile_pics/defaults/head_sun_flower.png new file mode 100644 index 0000000..d2ae270 Binary files /dev/null and b/assets/profile_pics/defaults/head_sun_flower.png differ diff --git a/assets/profile_pics/defaults/head_turqoise.png b/assets/profile_pics/defaults/head_turqoise.png new file mode 100644 index 0000000..b392480 Binary files /dev/null and b/assets/profile_pics/defaults/head_turqoise.png differ diff --git a/assets/profile_pics/defaults/head_wet_asphalt.png b/assets/profile_pics/defaults/head_wet_asphalt.png new file mode 100644 index 0000000..fe13767 Binary files /dev/null and b/assets/profile_pics/defaults/head_wet_asphalt.png differ diff --git a/assets/profile_pics/defaults/head_wisteria.png b/assets/profile_pics/defaults/head_wisteria.png new file mode 100644 index 0000000..27b23ea Binary files /dev/null and b/assets/profile_pics/defaults/head_wisteria.png differ diff --git a/register.php b/register.php index 2285120..669509f 100644 --- a/register.php +++ b/register.php @@ -1,5 +1,11 @@ 0) { + array_push($errors, "email_exists"); + } } else { - echo "invalid format"; + array_push($errors, "email_invalid"); } } else { - echo "The email's do not match."; + array_push($errors, "email_mismatch"); } + + if (strlen($fname) > 25 || strlen($fname) < 2) { + array_push($errors, "fname_invalid"); + } + + if (strlen($lname) > 25 || strlen($lname) < 2) { + array_push($errors, "lname_invalid"); + } + + if ($pass != $pass_conf) { + array_push($errors, "pass_mismatch"); + } else { + if(preg_match('/[^A-Za-z0-9]/', $pass)) { + array_push($errors, "pass_invalid_char"); + } else { + if (strlen($pass) > 30 || strlen($pass) < 5) { + array_push($errors, "pass_invalid_length"); + } + } + } + + if (empty($errors)) { + $pass = password_hash($pass, PASSWORD_BCRYPT); // Encrypts password + $username = strtolower($fname . "." . $lname); + $check_username_query = mysqli_query($con, "SELECT username FROM users WHERE username='$username'"); + + $i = 0; + $temp = $username; + while (mysqli_num_rows($check_username_query) != 0) { + $i++; + $temp = $username . $i; + $check_username_query = mysqli_query($con, "SELECT username FROM users WHERE username='$temp'"); + } + if ($i > 0) { + $username = $username . $i; + } + + $rand = rand(1,16); + $profile_pic = random_profile_pic($rand); + + $query = mysqli_query($con, "INSERT INTO users VALUES (NULL,'$fname','$lname','$username','$email','$pass','$date','$profile_pic','0','0','0',',')"); + } +} + +function random_profile_pic($rand) { + $profile_pic = "assets/profile_pics/defaults/"; + switch ($rand) { + case 1: + $profile_pic = $profile_pic . "head_alizarin.png"; + break; + case 2: + $profile_pic = $profile_pic . "head_amethyst.png"; + break; + case 3: + $profile_pic = $profile_pic . "head_belize_hole.png"; + break; + case 4: + $profile_pic = $profile_pic . "head_carrot.png"; + break; + case 5: + $profile_pic = $profile_pic . "head_deep_blue.png"; + break; + case 6: + $profile_pic = $profile_pic . "head_emerald.png"; + break; + case 7: + $profile_pic = $profile_pic . "head_green_sea.png"; + break; + case 8: + $profile_pic = $profile_pic . "head_nephritis.png"; + break; + case 9: + $profile_pic = $profile_pic . "head_pete_river.png"; + break; + case 10: + $profile_pic = $profile_pic . "head_pomegranate.png"; + break; + case 11: + $profile_pic = $profile_pic . "head_pumpkin.png"; + break; + case 12: + $profile_pic = $profile_pic . "head_red.png"; + break; + case 13: + $profile_pic = $profile_pic . "head_sun_flower.png"; + break; + case 14: + $profile_pic = $profile_pic . "head_turqoise.png"; + break; + case 15: + $profile_pic = $profile_pic . "head_wet_asphalt.png"; + break; + case 16: + $profile_pic = $profile_pic . "head_wistera.png"; + break; + } + return $profile_pic; } ?> @@ -64,18 +176,56 @@ if(isset($_POST['register_but'])) {
- +
- + + "; ?> + +
- + + "; ?> + +
- +
+ + "; + else if(in_array("email_invalid", $errors)) + echo "Invalid format
"; + else if(in_array("email_mismatch", $errors)) + echo "The email's do not match.
"; + ?> +

+ + "; + else if(in_array("pass_invalid_char", $errors)) + echo "Your password can only contain english characters or numbers.
"; + else if(in_array("pass_invalid_length", $errors)) + echo "Your password must be between 5 and 30 characters.
"; ?> +