-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
33 lines (29 loc) · 1.11 KB
/
signup.php
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
<?php
require('DB_connection.php');
if(isset($_POST['submit']))
{
$fname = mysqli_real_escape_string($conn, $_POST['fname']);
$lname = mysqli_real_escape_string($conn, $_POST['lname']);
$uname = mysqli_real_escape_string($conn, $_POST['uname']);
//hashing
$password = mysqli_real_escape_string($conn, $_POST['password']);
$password=stripcslashes($password);
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$fname=stripcslashes($fname);
$lname=stripcslashes($lname);
$uname=stripcslashes($uname);
$email=stripcslashes($email);
$query = "INSERT INTO user (f_name, l_name, username, password, email, Privilege) VALUES (?, ?, ?, ?, ?, 'U')";
$stmt = mysqli_prepare($conn , $query);
mysqli_stmt_bind_param($stmt , "sssss" , $fname , $lname , $uname, $hashed_password, $email);
mysqli_stmt_execute($stmt);
if(mysqli_stmt_affected_rows($stmt) == 1)
{
include('signin.html');
} else
{
echo 'ERROR: '. mysqli_error($conn);
}
}
?>