<?php
require_once('../config.php');

$users = mysqli_query($db, "SELECT * FROM users");
while($row = mysqli_fetch_assoc($users)){
    $hashEmail = preg_replace('/[^\w\s]/', '', base64_encode(sha1($row['email'], true)));
    $q = mysqli_query($db, "UPDATE users SET hash_email='$hashEmail' WHERE id='$row[id]'");
    if($q){
        echo "Email hashed updated for user {$row['id']}<br>\r\n";
    }else{
        echo "Error updating email for user {$row['id']}: ". mysqli_error($db). "<br>\r\n";
        exit();
    }
}


?>