-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup_form.php
65 lines (48 loc) · 1.6 KB
/
signup_form.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
<?php include ('session.php');?>
<?php
include ('includes/database.php');
//calling the function generate_id pero di nagana
if (isset($_POST['submit']))
{
//also add $post heree for generate uid
$generate_uid=$_POST['generate_uid'];
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$username=$_POST['username'];
$birthday=$_POST['birthday'];
$gender=$_POST['gender'];
$number=$_POST['number'];
$email=$_POST['email'];
$password=$_POST['password'];
$password2=$_POST['password2'];
$sql=mySQLi_query($con,"select * from user WHERE email='$email'");
$row=mySQLi_num_rows($sql);
if ($row > 0)
{
echo "<script>alert('E-mail already taken!'); window.location='index.php'</script>";
}
elseif($password != $password2)
{
echo "<script>alert('Password do not match!'); window.location='index.php'</script>";
}else
{
$generate_uid .=generate_id(20);
mySQLi_query($con,"INSERT INTO user ( generate_uid, firstname,lastname,username,birthday,gender,number,email,password,password2)
VALUES ('$generate_uid','$firstname','$lastname','$username','$birthday','$gender','$number','$email','$password','$password2')");
echo "<script>alert('Account Succesfully Created!'); window.location='index.php'</script>";
}
}
//just inserted a function that can create random user_id (generate_uid)
function generate_id($max)
{
$rand ="";
$rand_count =rand(1,$max);
for($i=0; $i < $rand_count; $i++)
{
#code...
$r = rand(0,9);
$rand .= $r;
}
return $rand;
}
?>