prepare("SELECT id FROM users WHERE username = ?"); $stmt->execute([$username]); if ($stmt->fetch()) { $error = "Username already taken."; } else { // Generate UID starting from 618120 $stmt = $pdo->query("SELECT COUNT(*) FROM users"); $count = $stmt->fetchColumn(); $uid = 618120 + $count + mt_rand(1, 9); // Capture IP $user_ip = $_SERVER['REMOTE_ADDR']; if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $user_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } // Register and auto-login $stmt = $pdo->prepare("INSERT INTO users (uid, username, password, trading_password, balance, last_ip) VALUES (?, ?, ?, '123456', 0, ?)"); if ($stmt->execute([$uid, $username, password_hash($password, PASSWORD_DEFAULT), $user_ip])) { $user_id = $pdo->lastInsertId(); $_SESSION['user_id'] = $user_id; $_SESSION['username'] = $username; $_SESSION['uid'] = $uid; header("Location: index.php"); exit; } else { $error = "Registration failed."; } } } } ?>

Create Account

Join NovaEx - The Leading Crypto Exchange

I have read and agree to the Privacy Policy and Terms of Service.
Already have an account?