functions.php 587 Bytes
Newer Older
Vane Milevski's avatar
Vane Milevski committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php

function usernameClean($username){

    $username = trim($username);
    $invalidChars = ["!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "=", "+"];
    $username = str_replace($invalidChars, "", $username);
    $username = preg_replace('/[^a-zA-Z0-9\-]/', '', $username);

    return $username;
}

function emailClean($email){
    
    $email = trim($email);
    if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
        return $email;
    } else {
        return false; 
    }
}

function hashedPassword($password){
    return password_hash($password, PASSWORD_DEFAULT);
}

?>