Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $fname=$_POST["fname"];
- $lname=$_POST["lname"];
- $email=$_POST["email"];
- $username=$_POST["username"];
- $con_password=$_POST["con_password"];
- $password=$_POST["password"];
- // start checking if any input errors
- if( ($password != $con_password) || $username=="")
- die("sorry but the passwords need to match");
- $db = new PDO('mysql:host=127.0.0.1;dbname=dropbin;charset=utf8', '', '');
- // check that the username doesnt exist already
- $stmt = $db->query("SELECT * FROM user where username='$username' ");
- if(($row = $stmt->fetch(PDO::FETCH_ASSOC)))
- die("user $username already exists <br>");
- //encrypt password
- $password=md5($password);
- // insert this new user
- $stmt=$db->prepare("insert into user (first_name, last_name, email, username, password) values (:first_name, :last_name,:email,:username,:password)");
- $stmt->execute(array(
- "first_name" => "$fname",
- "last_name" => "$lname",
- "email" => "$email",
- "username" => "$username",
- "password" => "$password"
- ));
- $user_id=$db->lastInsertId();
- echo " last inserted "+$user_id;
- //create a home folder
- $dir=$username;
- if (!file_exists($dir) && !is_dir($dir))
- mkdir($dir);
- else
- echo "exists";
- // insert the new folder
- $stmt=$db->prepare("insert into folder (folder_name, folder_comment,folder_user_id) values (:folder_name, :folder_comment,:folder_user_id)");
- $stmt->execute(array(
- "folder_name" => "$dir",
- "folder_comment" => "DEFAULT",
- "folder_user_id" => "$user_id"
- ));
- echo "user $username has been registered successfully ";
- ?>
- <a href="index.php" > Login here </a>
Advertisement
Add Comment
Please, Sign In to add comment