-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsert_user.php
60 lines (48 loc) · 2.4 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
54
55
56
57
58
59
60
<?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']));
$country = htmlentities(mysqli_real_escape_string($con,$_POST['u_country']));
$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($con,$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();
}
$rand = rand(1, 3); //Random number between 1 and 3
if($rand == 1)
$profile_pic = "head_red.png";
else if($rand == 2)
$profile_pic = "head_sun_flower.png";
else if($rand == 3)
$profile_pic = "head_turqoise.png";
$insert = "insert into users (f_name,l_name,user_name,describe_user,Relationship,user_pass,user_email,user_country,user_gender,user_birthday,user_image,user_cover,user_reg_date,status,posts,recovery_account)
values('$first_name','$last_name','$username','Hello Social Circle.This is my default status!','...','$pass','$email','$country','$gender','$birthday','$profile_pic','default_cover.jpg',NOW(),'$status','$posts','Iwanttoputading intheuniverse.')";
$query = mysqli_query($con, $insert);
if($query){
echo "<script>alert('Well Done $first_name, you are good to go.')</script>";
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>";
}
}
?>