Skip to content

Commit

Permalink
removed emails
Browse files Browse the repository at this point in the history
  • Loading branch information
KotsiosDimis committed Dec 27, 2024
1 parent 63fec0b commit df0f447
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
13 changes: 8 additions & 5 deletions lib/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
header('Content-Type: application/json');

// **Registration Function (Register a new user)**
function registerUser($username, $email, $password) {
function registerUser($username, $password) {
try {
$pdo = getDatabaseConnection();
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);

$sql = "INSERT INTO users (username, password_hash, email) VALUES (:username, :password, :email)";
$sql = "INSERT INTO users (username, password_hash) VALUES (:username, :password)";
$stmt = $pdo->prepare($sql);
$stmt->execute([
':username' => $username,
':password' => $hashedPassword,
':email' => $email,
]);

echo json_encode(['success' => true, 'message' => 'User registered successfully']);
Expand Down Expand Up @@ -79,8 +78,12 @@ function checkSession() {
}
}



// FUTER UPDATE fuachers ///
// **Reset Password Function (Send Password Reset Email)**
function resetPassword($email) {
/*
function resetPassword($email) {
try {
$pdo = getDatabaseConnection();
$sql = "SELECT id FROM users WHERE email = :email";
Expand Down Expand Up @@ -127,6 +130,6 @@ function updatePassword($userId, $newPassword) {
} catch (PDOException $e) {
echo json_encode(['success' => false, 'message' => 'Error: ' . $e->getMessage()]);
}
}
} */

?>
4 changes: 0 additions & 4 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ <h4 class="text-center">Register</h4>
<label for="reg_username">Username</label>
<input type="text" class="form-control" id="reg_username" placeholder="Username" required />
</div>
<div class="form-group">
<label for="reg_email">Email</label>
<input type="email" class="form-control" id="reg_email" placeholder="Email" required />
</div>
<div class="form-group">
<label for="reg_password">Password</label>
<input type="password" class="form-control" id="reg_password" placeholder="Password" required />
Expand Down
3 changes: 1 addition & 2 deletions public/js/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ $(document).ready(function () {
e.preventDefault(); // Prevent default form submission

const username = $('#reg_username').val();
const email = $('#reg_email').val();
const password = $('#reg_password').val();

$('#debugInfo').append(`<p>Attempting to register with: Username - <b>${username}</b>, Email - <b>${email}</b></p>`);
Expand All @@ -49,7 +48,7 @@ $(document).ready(function () {
url: 'https://users.iee.ihu.gr/~iee2020202/ADISE24_DreamTeam/blokus.php/users/register',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({ username: username, email: email, password: password }),
data: JSON.stringify({ username: username, password: password }),
success: function (response) {
$('#debugInfo').append(`<p>Response received from server: <pre>${JSON.stringify(response)}</pre></p>`);

Expand Down

0 comments on commit df0f447

Please sign in to comment.