-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignUpProcess.php
More file actions
42 lines (35 loc) · 1.81 KB
/
Copy pathsignUpProcess.php
File metadata and controls
42 lines (35 loc) · 1.81 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
<?php
include "connection.php";
$fullname = $_POST['fullname'];
$username = $_POST['username'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$password = MD5($_POST['password']);
$role_id = $_POST['role_id'];
$profile_pict = $_FILES['profile_pict']['name'];
$target_path="uploads/profile_pict/";
$target_path = $target_path . basename($profile_pict);
$query = "SELECT * FROM users WHERE username = '$username' OR phone = '$phone' OR email = '$email'";
$result = mysqli_query($connect, $query);
if (mysqli_num_rows($result) > 0) {
echo "<script>alert('Username atau email atau nomor telp sudah pernah dipakai." . mysqli_error($connect) . "'); window.location.href='signUp.html'</script>";
}
move_uploaded_file($_FILES['profile_pict']['tmp_name'], $target_path);
$query = "INSERT INTO users (fullname, username, address, phone, email, password, role_id, profile_pict) VALUES
('$fullname', '$username', '$address', '$phone', '$email', '$password', $role_id, '$profile_pict')";
if (mysqli_query($connect, $query)) {
session_start();
$_SESSION['username'] = $username;
$_SESSION['user_id'] = $row['user_id'];
$_SESSION['role_id'] = $role_id;
$_SESSION['login'] = true;
if($role_id == 1){
echo "<script>alert('Alhamdulillah udah bisa'); window.location.href='homeVendor.php'</script>";
} else if($role_id == 2){
echo "<script>alert('Alhamdulillah udah bisa'); window.location.href='homeUser.php'</script>";
}
} else {
echo "<script>alert('Gaiso su." . mysqli_error($connect) . "'); window.location.href='signUp.php'</script>";
}
?>