Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
chathaj committed Nov 15, 2024
1 parent e4a7229 commit 0c44c50
Show file tree
Hide file tree
Showing 33 changed files with 1,730 additions and 0 deletions.
35 changes: 35 additions & 0 deletions gamerevs/check_username.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
// check_username.php

$host = 'localhost';
$db = 'game_review_website';
$user = 'root';
$pass = '';

$conn = new mysqli($host, $user, $pass, $db);

if ($conn->connect_error) {
die('Connection failed: ' . $conn->connect_error);
}

if (isset($_GET['username'])) {
$username = trim($_GET['username']);

// Prepare statement to prevent SQL injection
$stmt = $conn->prepare('SELECT id FROM users WHERE username = ?');
$stmt->bind_param('s', $username);
$stmt->execute();
$stmt->store_result();

// If username exists, output 'taken', else 'available'
if ($stmt->num_rows > 0) {
echo 'taken';
} else {
echo 'available';
}

$stmt->close();
}

$conn->close();
?>
Loading

0 comments on commit 0c44c50

Please sign in to comment.