-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_student.php
More file actions
27 lines (22 loc) Β· 1.09 KB
/
Copy pathcreate_student.php
File metadata and controls
27 lines (22 loc) Β· 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
require_once 'config/database.php';
// Check if student already exists
$check = fetchOne("SELECT user_id FROM users WHERE email = 'john.doe@student.edu'");
if ($check) {
echo "Student already exists. Updating password...<br>";
$password_hash = password_hash('student123', PASSWORD_DEFAULT);
executeQuery("UPDATE users SET password_hash = ? WHERE email = 'john.doe@student.edu'", [$password_hash]);
echo "β
Student password updated to: student123<br>";
} else {
echo "Creating new student account...<br>";
$password_hash = password_hash('student123', PASSWORD_DEFAULT);
$sql = "INSERT INTO users (student_id, first_name, last_name, email, password_hash, phone, year_level, gender, program, user_role)
VALUES ('STU2024001', 'John', 'Doe', 'john.doe@student.edu', ?, '1234567891', '1', 'Male', 'Computer Science', '
student')";
executeQuery($sql, [$password_hash]);
echo "β
Student account created!<br>";
echo "Email: john.doe@student.edu<br>";
echo "Password: student123<br>";
}
echo "<br><a href='auth/login.php'>Go to Login</a>";
?>