-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
51 lines (40 loc) · 1.47 KB
/
functions.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php include "db.php"; ?>
<?php
//Resister a new user to our platfrom
function creatUser(){
global $connect;
if (isset($_POST['resister'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$address = $_POST['address'];
// MySql security function
$username = mysqli_real_escape_string($connect, $username);
$password = mysqli_real_escape_string($connect, $$password);
$email = mysqli_real_escape_string($connect, $email);
$phone = mysqli_real_escape_string($connect, $phone);
$address = mysqli_real_escape_string($connect, $address);
//Encrypted password
$hassedPass = sha1($password);
$query = "INSERT INTO users (username, password, user_email, user_phone, user_address ) VALUES('$username',' $hassedPass',' $email', '$phone', '$address')";
$creat_new_user = mysqli_query($connect, $query);
if (!$creat_new_user) {
die("Query Failed" . mysqli_error($connect));
}
else{
header("Location: all-users.php");
}
}
}
//Detele users info form the all-users table
function deleteUser(){
global $connect;
if (isset($_GET['delete'])) {
$the_user_id = $_GET['delete'];
$query = "DELETE FROM users WHERE user_id = $the_user_id";
$delete_user = mysqli_query($connect, $query);
header("Location: all-users.php");
}
}
?>