-
Notifications
You must be signed in to change notification settings - Fork 2
/
signup_api.php
135 lines (121 loc) · 5.25 KB
/
signup_api.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
<?php
require('db.php');
if (isset($_REQUEST['username'])) {
$username = stripslashes($_REQUEST['username']);
$username = mysqli_real_escape_string($con, $username);
$fullname = stripslashes($_REQUEST['fullname']);
$fullname = mysqli_real_escape_string($con, $fullname);
$email = stripslashes($_REQUEST['email']);
$email = mysqli_real_escape_string($con, $email);
$password = stripslashes($_REQUEST['password']);
$password = mysqli_real_escape_string($con, $password);
$create_datetime = date("Y-m-d H:i:s");
#$myfile = fopen(dirname(__FILE__) . "../users/$username", "w") or die("Server has issued rejection code!");
#$txt = "Data 1:\n";
#fwrite($myfile, $txt);
#$txt = "Data 2:\n";
#fwrite(dirname(__FILE__) . $myfile, $txt);
#fclose($myfile);
$query = "INSERT into `users` (username, password, email, create_datetime, bio, url, location, full_name)
VALUES ('$username', '" . md5($password) . "', '$email', '$create_datetime', 'No bio yet!', 'Maybe https://$username.com', '', '$fullname')";
$result = mysqli_query($con, $query);
if ($result) {
header("location: ../login.php");
} else {
echo '<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Untitled</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<div class="login-dark">
<form class="form" action="" method="post">
<h2 class="sr-only">Signup Form</h2>
<div class="illustration"><i class="icon ion-ios-locked-outline"></i></div>
<div class="form-group"><input class="form-control" type="name" name="username" placeholder="username"></div>
<div class="form-group"><input class="form-control" type="email" name="email" placeholder="Email Address"></div>
<div class="form-group"><input class="form-control" type="password" name="password" placeholder="Password"></div>
<p style="color:red">Unkown error, please try again or contact support.</p>
<div class="form-group"><button class="btn btn-primary btn-block" type="submit">Signup</button></div><a href="../login.php" class="forgot">Member? login now</a></form>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.bundle.min.js"></script>
</body>
</html>
<style>
.login-dark {
height:1000px;
background:#475d62 url(images/1.png);
background-size:cover;
position:relative;
}
.login-dark form {
max-width:320px;
width:90%;
background-color:black;
padding:40px;
border-radius:4px;
transform:translate(-50%, -50%);
position:absolute;
top:50%;
left:50%;
color:#fff;
box-shadow:3px 3px 4px rgba(0,0,0,0.2);
}
.login-dark .illustration {
text-align:center;
padding:15px 0 20px;
font-size:100px;
color:#2980ef;
}
.login-dark form .form-control {
background:none;
border:none;
border-bottom:1px solid #434a52;
border-radius:0;
box-shadow:none;
outline:none;
color:inherit;
}
.login-dark form .btn-primary {
background:#214a80;
border:none;
border-radius:4px;
padding:11px;
box-shadow:none;
margin-top:26px;
text-shadow:none;
outline:none;
}
.login-dark form .btn-primary:hover, .login-dark form .btn-primary:active {
background:#214a80;
outline:none;
}
body {
overflow: hidden; /* Hide scrollbars */
}
.login-dark form .forgot {
display:block;
text-align:center;
font-size:12px;
color:#6f7a85;
opacity:0.9;
text-decoration:none;
}
.login-dark form .forgot:hover, .login-dark form .forgot:active {
opacity:1;
text-decoration:none;
}
.login-dark form .btn-primary:active {
transform:translateY(1px);
}
</style>';
}
} else {
echo '<h1>Connection has been blocked!</h1>';
}