-
Notifications
You must be signed in to change notification settings - Fork 1
/
user-signup.php
180 lines (161 loc) · 6.84 KB
/
user-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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
/********************************
* File Name: user-signup.php *
* Author: Ammar S.A.A *
* Output: User Signup Form *
********************************/
require('config.php');
require(WEBSITE_PATH.'./includes/db_connection.php');
require(WEBSITE_PATH.'./includes/session.php');
include(WEBSITE_PATH.'./includes/header.php');
include(WEBSITE_PATH.'./includes/logo.php');
include(WEBSITE_PATH.'./includes/menu.php');
// perform user signup
if (isset($_POST['user-signup']))
{
$full_name = trim($_POST['full_name']);
$email_id = trim($_POST['email_id']);
$password = $_POST['password'];
$mobile_no = trim($_POST['mobile_no']);
if(isset($_GET['id'])){
$status = $_POST['status'];
}
$user_name = trim($_POST['user_name']);
$profile_picture = $_FILES['profile_picture']['name'];
$profile_pic_tmp = $_FILES['profile_picture']['tmp_name'];
//Moves uploaded Profile Pictures to a permenent location
move_uploaded_file($profile_pic_tmp,"./images/profile_pictures/$profile_picture");
if (!empty($email_id) && !empty($password)){
if (isset($_GET['id']))
{
if(empty($profile_picture))
{
$sql_profile_pic = "SELECT * FROM `tblusers` WHERE id = '{$_GET['id']}' ";
$sql = $conn->query($sql_profile_pic);
while($row = mysqli_fetch_array($sql)) {
$profile_picture = $row['profile_picture'];
}
}
$sql = "UPDATE tblusers SET
`full_name` = '{$full_name}',
`email_id` = '{$email_id}',
`mobile_no` = '{$mobile_no}',
`user_name` = '{$user_name}',
`status` = '{$status}',
`password` = '{$password}',
`profile_picture` = '{$profile_picture}'
WHERE id = {$_POST['id']}";
}
else{
$sql = "INSERT INTO `tblusers`(`full_name`, `email_id`, `mobile_no`, `user_name`, `password`, `profile_picture`)
VALUES ('{$full_name}','{$email_id}','{$mobile_no}', '{$user_name}', '{$password}','{$profile_picture}')";
}
$result = $conn->query($sql);
if ($result && !$_GET['id'])
{
$msg = "<div class='alert alert-success text-capitalize'>Registration successful!</div>";
}elseif ($result && isset($_GET['id']))
{
$msg = "<div class='alert alert-success text-capitalize'>Updation successful!</div>";
}else{
$msg = "<div class='alert alert-danger text-capitalize'>Errors occured! or if you has changed the user name so this user name(".$user_name.") already exist.</div>";
}
}else{
$msg = "E-mail or Password can not be empty";
}
}
$full_name = '';
$email_id = '';
$mobile_no = '';
$user_name = '';
$password = '';
$status = '';
$profile_picture = '';
if (isset($_GET['id']))
{
$select = "SELECT * FROM `tblusers` where id={$_GET['id']}";
$result = $conn->query($select);
if ($result && $result->num_rows > 0){
$row = $result->fetch_assoc();
$id = $row['id'];
$full_name = $row['full_name'];
$email_id = $row['email_id'];
$user_name = $row['user_name'];
$password = $row['password'];
$mobile_no = $row['mobile_no'];
$status = $row['status'];
$profile_picture = $row['profile_picture'];
};
}
if (isset($msg))
{
echo $msg;
}
?>
<section id="content">
<div class="page-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col">
<!--SignUp Form-->
<form class="" name="user-signup" method="post" action="#" enctype="multipart/form-data" onsubmit="return checkForm(this);">
<br />
<input type="hidden" name="user-signup" value="user-signup" />
<input type="hidden" name="id" value="<?php echo $id;?>" />
<img class="f-img img-circle" src="<?php echo WEBSITE_URL; ?>/images/profile_pictures/<?php if(empty($profile_picture)){ echo '../monitor_mlms.png'; }else{ echo $profile_picture; } ?>" />
<h2>User</h2>
<p>Signup Form</p>
<p class="labelenglish"><b>Profile Picture:</b></p>
<input title="Upload Profile Picture, not more than 11 MB" type="file" accept="img/*" value="<?php echo $profile_picture ?>" name="profile_picture" class="labelenglish text-uppercase" />
<p class="labelenglish"><small><b>Note:</b><br /> Your <b class="text-uppercase text-right"><?php if(empty($profile_picture)){ echo 'Profile Picture'; }else{ echo $profile_picture; } ?></b> must not be more than <b>11 MB</b>.</small></p>
<p class="labelenglish"><b>Full Name:</b></p>
<input title="Enter Your Full Name" value="<?php echo $full_name ?>" type="text" name="full_name" pattern="\w+++" class="blank" required />
<p class="labelenglish"><b>E-mail:</b></p>
<input title="Enter Your E-mail" type="email" value="<?php echo $email_id ?>" name="email_id" class="blank" required />
<p class="labelenglish"><b>User Name:</b></p>
<input title="Enter Desired User Name" type="text" value="<?php echo $user_name ?>" name="user_name" class="blank" required />
<p class="labelenglish"><b>Password:</b></p>
<input title="Enter Password" value="<?php echo $password ?>" type="password" name="password" class="blank" required />
<p class="labelenglish"><b>Mobile No.:</b></p>
<input title="Enter your Contact No." type="number" value="<?php echo $mobile_no ?>" name="mobile_no" placeholder="Without dashes or spaces" class="blank" required />
<?php
if (isset($_GET["id"])) {
?>
<p class="labelenglish"><b>Status:</b></p><br />
<div class="form-check form-check-inline" name="status">
<input class="form-check-input" type="radio" name="status" value="Active" <?php if ($status === 'Active') { echo "Checked"; } elseif ($status === 'Inactive') { echo " "; } else { echo " ";}?> />
<label class="form-check-label" for="status">
Active
</label>
</div>
<div class="form-check form-check-inline" name="status">
<input class="form-check-input" type="radio" name="status" value="Inactive" <?php if ($status === 'Inactive') { echo "Checked"; } elseif ($status === 'Active') { echo " "; } else { echo " ";}?> />
<label class="form-check-label" for="status">
Inactive
</label>
</div>
<?php } ?>
<div>
<input type="reset" name="reset" value="Reset" class="btn btn-success"/>
<?php
if (isset($_GET['id'])) {
echo "<input type='submit' name='submit' value='Update' class='btn btn-success' />";
}
else{
echo "<input type='submit' name='submit' value='Signup' class='btn btn-success' />";
}
?>
</div>
<p>By signing up you agree our <a href="<?php echo WEBSITE_URL; ?>./rule_list.php">RULES AND REGULATIONS</a>.</p>
<br />
</form>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
<?php
include(WEBSITE_PATH.'./includes/footer.php');
?>