Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- require_once('db.php');
- $sql1 = "SELECT username FROM administrators WHERE username = '.$username.' ";
- $cmd = $conn->prepare($sql1);
- $cmd->execute();
- $admin = $cmd->fetchAll();
- //if the username is greater than 0 in the database say that username already exists
- if (empty($admin_id) == true){
- //set up the sql command
- $sql = "INSERT INTO administrators (username, password) VALUES (:username, :password)";
- }else{
- $sql ="UPDATE administrators SET username = :username, password = :password WHERE admin_id = :admin_id";
- }
- //5. hash the password for added security
- $hashed_password = hash('sha512', $password);
- //6. execute the save
- $cmd = $conn->prepare($sql);
- $cmd->bindParam(':username', $username, PDO::PARAM_STR, 50);
- $cmd->bindParam(':password', $hashed_password, PDO::PARAM_STR, 128);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement