-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_user.php
More file actions
54 lines (47 loc) · 1.62 KB
/
create_user.php
File metadata and controls
54 lines (47 loc) · 1.62 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
require_once 'scripts/database.php';
require_once 'scripts/app_config.php';
$username = $_POST['username'];
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
$username = filter_var($username, FILTER_SANITIZE_STRING);
$username = mysqli_real_escape_string($con, $username);
if(isset($_POST['student-btn'])){
$sql = "INSERT INTO tblStudents(username,password)VALUES(?,?);";
$stmt = mysqli_stmt_init($con);
if(!mysqli_stmt_prepare($stmt,$sql)){
echo "Error in prepare statment";
} else{
mysqli_stmt_bind_param($stmt, "ss", $username, $password);
mysqli_stmt_execute($stmt);
session_start();
$_SESSION['student_id'] = $student_id;
header("Location:student.php");
}
}
if(isset($_POST['faculty-btn'])){
$sql = "INSERT INTO tblAdvisors(username,password)VALUES(?,?);";
$stmt = mysqli_stmt_init($con);
if(!mysqli_stmt_prepare($stmt,$sql)){
echo "Error in prepare statment";
} else{
mysqli_stmt_bind_param($stmt, "ss", $username, $password);
mysqli_stmt_execute($stmt);
session_start();
$_SESSION['advisor_id'] = $advisor_id;
header("Location:advisor.php");
}
}
if(isset($_POST['tutor-btn'])){
$sql = "INSERT INTO tblTutors(username,password)VALUES(?,?);";
$stmt = mysqli_stmt_init($con);
if(!mysqli_stmt_prepare($stmt,$sql)){
echo "Error in prepare statment";
} else{
mysqli_stmt_bind_param($stmt, "ss", $username, $password);
mysqli_stmt_execute($stmt);
session_start();
$_SESSION['tutor_id'] = $tutor_id;
header("Location:tutor.php");
}
}
?>