JezK
Edit File: sync_users.php
<?php $pdo = new PDO("mysql:host=127.0.0.1;dbname=intranet", "root", ""); $usuarios = $pdo->query("SELECT * FROM USUARIO")->fetchAll(PDO::FETCH_ASSOC); foreach ($usuarios as $u) { $name = $u['USUARIO']; $email = strtolower($name) . "@local.com"; $password = password_hash("123456", PASSWORD_BCRYPT); // verificar si existe $check = $pdo->prepare("SELECT id FROM users WHERE name = ?"); $check->execute([$name]); if ($check->rowCount() == 0) { $insert = $pdo->prepare(" INSERT INTO users (role_id, name, email, password, created_at, updated_at) VALUES (1, ?, ?, ?, NOW(), NOW()) "); $insert->execute([$name, $email, $password]); echo "Creado: $name\n"; } } echo "SYNC COMPLETADO\n";