-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert_user.php
53 lines (41 loc) · 2.04 KB
/
insert_user.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
<?php
include("includes/connection.php");
if (isset($_POST['sign_up'])) {
$first_name = htmlentities(mysqli_real_escape_string($con,$_POST['first_name']));
$last_name = htmlentities(mysqli_real_escape_string($con,$_POST['last_name']));
$pass = htmlentities(mysqli_real_escape_string($con,$_POST['u_pass']));
$email = htmlentities(mysqli_real_escape_string($con,$_POST['u_email']));
$dis = htmlentities(mysqli_real_escape_string($con,$_POST['u_district']));
$gender = htmlentities(mysqli_real_escape_string($con,$_POST['u_gender']));
$birthday = htmlentities(mysqli_real_escape_string($con,$_POST['u_birthday']));
$status = "verified";
$posts = "no";
$newgid = sprintf('%05d', rand(0, 999999));
$username = strtolower($first_name . "_" . $last_name . "_" . $newgid);
$check_username_query = "select user_name from users where user_email='$email'";
$run_username = mysqli_query($con,$check_username_query);
if(strlen($pass) <9 ){
echo "<script>alert('Password should be minimum 9 characters!')</script>";
exit();
}
$check_email = "select * from users where user_email='$email'";
$run_email = mysqli_query($check_email);
$check = mysqli_num_rows($run_email);
if ($check == 1) {
echo "<script>alert('Email already exist, Please try using another email')</script>";
echo "<script>window.open('signup.php', '_self')</script>";
exit();
}
$profile_pic = "images.png";
$insert = "insert into users (f_name,l_name,user_name,describe_user,user_pass,user_email,user_dis,user_gender,user_birthday,user_image,user_cover,user_reg_date,status,posts,recovery_account)
values('$first_name','$last_name','$username','USER','$pass','$email','$dis','$gender','$birthday','$profile_pic','download.jpg',NOW(),'status','$posts','DCMA.')";
$query = mysqli_query($con, $insert);
if ($query) {
echo "<script>window.open('signin.php', '_self')</script>";
}
else{
echo "<script>alert('Registration failed,please try again!')</script>";
echo "<script>window.open('signup.php', '_self')</script>";
}
}
?>