-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup_action.php
134 lines (73 loc) · 2.9 KB
/
signup_action.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
session_start();
include('config.php');
if(isset($_POST['signup_btn']))
{
$full_name = $_POST['full_name'];
$user_name= $_POST['user_name'];
$user_type = "1";
$email_address= $_POST['email'];
$facebook = "www.facebook.com";
$whatsapp = "www.webwhatsapp.com";
$bio = "tell use more about you";
$fallowers = 0;
$fallowing = 0;
$post_count = 0;
$image = "assets/images/default.png";
$password= $_POST['password'];
$password_confirm= $_POST['retype_password'];
//echo $full_name;
if($password != $password_confirm)
{
$message_error = "error message";
header('location: WelCome?error_message=Passwords can not verify');
exit;
}
// check user availibility
$sql_query = "SELECT User_ID FROM USERS WHERE USER_NAME = '$user_name' OR EMAIL = '$email_address';";
//echo $sql_query;
$stmt = $conn->prepare($sql_query);
//$stmt->bind_param("ss",$user_name, $email_address);
$stmt->execute();
$stmt->store_result();
if($stmt->num_rows() > 0)
{
echo 'user name already exists';
header('location: WelCome?error_message=user already exists');
exit;
}else{
$encrypted_password = md5($password);
$insert_query = "INSERT INTO users (FULL_NAME,USER_NAME,USER_TYPE,PASSWORD_S,EMAIL,IMAGE,FACEBOOK,WHATSAPP,BIO,FALLOWERS,FALLOWING,POSTS) VALUES
('$full_name', '$user_name', '$user_type', '$encrypted_password', '$email_address', '$image', '$facebook', '$whatsapp', '$bio', $fallowers, $fallowing, $post_count);";
$stmt->prepare($insert_query);
if($stmt->execute())
{
$data_select = "SELECT FULL_NAME,USER_NAME,USER_TYPE,EMAIL,IMAGE,FACEBOOK,WHATSAPP,BIO,FALLOWERS,FALLOWING,POSTS FROM users WHERE USER_NAME = '$user_name';";
$stmt = $conn->prepare($data_select);
$stmt->execute();
$stmt->bind_result($full_name, $user_name, $user_type, $email_address, $image, $facebook, $whatsapp, $bio, $fallowers, $fallowing, $post_count);
$stmt->fetch();
//$_SESSION['id'] = $User_ID;
$_SESSION['username'] = $user_name;
$_SESSION['fullname'] = $full_name;
$_SESSION['email'] = $email_address;
$_SESSION['usertype'] = $user_type;
$_SESSION['facebook'] = $facebook;
$_SESSION['whatsapp'] = $whatsapp;
$_SESSION['bio'] = $bio;
$_SESSION['fallowers'] = $fallowers;
$_SESSION['fallowing'] = $fallowing;
$_SESSION['postcount'] = $post_count;
$_SESSION['img_path'] = $image;
header("location: home.php");
}else{
header("location: WelCome?error_message=error occurred");
exit;
}
}
}else
{
header("location: WelCome?error_message=error occurred");
exit;
}
?>