Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if($_GET['action'] == "createAdmin") {
- $email = filter_input(INPUT_POST, 'email');
- $username = filter_input(INPUT_POST, 'username');
- $password = filter_input(INPUT_POST, 'password');
- $confirm = filter_input(INPUT_POST, 'confirm_password');
- $current_date = date("Y-m-d h:i:s a");
- $microTime = microtime();
- if($password == $confirm) {
- $hash_pass = crypt($password .$microTime);
- $pass_crypt = crypt($password); // let the salt be automatically generated
- $statement_insertAdmin = $conn->prepare("INSERT INTO admin_login(username, password, email, created_date, hash)
- VALUES(:user, :pass, :email, :created, :hash)");
- $statement_insertAdmin->execute(array(
- "user" => $username,
- "pass" => $pass_crypt,
- "email" => $email,
- "created" => $current_date,
- "hash" => $hash_pass
- ));
- //send verification email with hash
- $to = $email;
- $subject = "Admin Account Created";
- $htmlbody = 'Please click the link below to activate your admin account! <br><Br>
- <a href='http://www.companyname.com/admin/activate.php? a=1&h='.$hash.''>
- Activate Now </a>
- ';
- $headers = "MIME-Version: 1.0" . "rn";
- $headers .= "Content-type:text/html;charset=UTF-8" . "rn";
- // More headers
- $headers .= 'From: Company Name<email@email.com>';
- mail($to,$subject,$htmlbody,$headers);
- echo "created";
- }
- else {
- echo 'false confirm';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement