Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //We check if the form has been sent
- if(isset($_POST['username'], $_POST['password'], $_POST['passverif'], $_POST['email'], $_POST['avatar']) and $_POST['username']!='')
- {
- //We remove slashes depending on the configuration
- $_POST['username'] = stripslashes($_POST['username']);
- $_POST['password'] = stripslashes($_POST['password']);
- $_POST['passverif'] = stripslashes($_POST['passverif']);
- $_POST['email'] = stripslashes($_POST['email']);
- $_POST['avatar'] = stripslashes($_POST['avatar']);
- //We check if the two passwords are identical
- if($_POST['password']==$_POST['passverif'])
- {
- //We check if the password has 6 or more characters
- if(strlen($_POST['password'])>=6)
- {
- //We check if the email form is valid
- if(preg_match('#^(([a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+\.?)*[a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+)@(([a-z0-9-_]+\.?)*[a-z0-9-_]+)\.[a-z]{2,}$#i',$_POST['email']))
- {
- //We protect the variables
- $username = $pdo->quote($_POST['username']);
- $password = $pdo->quote($_POST['password']);
- $email = $pdo->quote($_POST['email']);
- $avatar = $pdo->quote($_POST['avatar']);
- //We check if there is no other user using the same username
- $stm = $pdo->query('SELECT id from users where username="'.$username.'"');
- $dn = $stm->rowCount();
- if($dn==0)
- {
- //We count the number of users to give an ID to this one
- $stm2 = $pdo->query('SELECT id from users');
- $dn2 = $stm2->rowCount();
- $id = $dn2+1;
- //We save the informations to the databse
- if($pdo->query('INSERT into users(id, username, password, email, avatar, signup_date) values ('.$id.', "'.$username.'", "'.$password.'", "'.$email.'", "'.$avatar.'", "'.time().'")'))
- {
- //We dont display the form
- $form = false;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement