-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsignup.php
61 lines (49 loc) · 1.75 KB
/
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
<?php
include 'conn.php';
$error = '';
if(isset($_POST['signup'])){
/*$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$email = mysql_real_escape_string($_POST['email']);*/
$username = $_POST['user'];
$password = $_POST['password'];
$email = $_POST['email'];
}
$action = array();
$action['result'] = null;
$text = array();
if(empty($username)){ $action['result'] = 'error';
array_push($text,'You forgot your username');
}
if(empty($password)){ $action['result'] = 'error';
array_push($text,'You forgot your password');
}
if(empty($email)){ $action['result'] = 'error';
array_push($text,'You forgot your email');
}
if($action['result'] != 'error'){
//no errors, continue signup
$password = md5($password);
$add = mysqli_query($conn,"INSERT INTO `users`(firstName,username,password,pic,email) VALUES('$username','$username','$password','https://avatars.servers.getgo.com/2205256774854474505_medium.jpg','$email')" );
if($add){
echo '<script> window.location="index.php";</script>';
//the user was added to the database
}else{
$action['result'] = 'error';
array_push($text,'User could not be added to the database. Reason: ' . mysql_error());
}
}
/*$action['text'] = $text;
$userid = mysql_insert_id();
//create a random key
$key = $username . $email . date('mY');
$key = md5($key);
//add confirm row
$confirm = mysql_query("INSERT INTO `confirm` VALUES(NULL,'$userid','$key','$email')");
if($confirm){
echo"Done";
}else{
$action['result'] = 'error';
array_push($text,'Confirm row was not added to the database. Reason: ' . mysql_error());
} */
?>