-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
324 lines (276 loc) · 8.64 KB
/
index.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
<?php
session_start();
$_SESSION['logged_user_name'] = null;
$conn = mysqli_connect("localhost","root","","blogspacedb");
if(mysqli_connect_error()){
die("error occured");
}
if (isset($_GET['user_signup_submit'])) {
$email_id = $_GET['user_email'];
$pass = $_GET['user_psd'];
$name = $_GET['user_name'];
$url = $_SERVER['REQUEST_URI'];
$pos = strpos($url,"&user_psd");
$substr = substr($url,$pos);
$url2 = str_ireplace($substr,"",$url);
//$url2 = "/blogtest/testfolder/?user_name=erza&user_email=dsvsd%40gmail.com";
$pos = strpos($url2,"?user_name");
//echo $pos."<br>";
$sub = substr($url2,$pos);
$profile_url = "profile.php".$sub;
//echo $profile_url;
$sql = "select * from userdetails where user_name='$name' ";
$result = $conn->query($sql);
$rowcount = mysqli_num_rows($result);
if($rowcount > 0){ ?>
<script type="text/javascript">
window.onload = function(){
document.getElementById("wel_box").style.display = 'none';
document.getElementById("signup_form_box").style.display = 'block';
document.getElementById("login_bxx").style.display = 'none';
}
</script>
<?php
}else{
$sql2 = "insert into userdetails (user_name,email_id,pass,profile_url) values ('$name','$email_id','$pass','$profile_url')";
$res = $conn->query($sql2);
if($res == true){
$_SESSION['logged_user_name'] = $name;
header("Location: ".$profile_url);
}
}
}
if (isset($_POST['user_login_submit'])) {
$name = $_POST['user_name'];
$pass = $_POST['user_pass'];
$sql3 = "select * from userdetails where user_name='$name' and pass='$pass'";
$ress = $conn->query($sql3);
$rowcount2 = mysqli_num_rows($ress);
if($rowcount2 == 1){
$row = $ress->fetch_assoc();
$url = $row['profile_url'];
$_SESSION['logged_user_name'] = $name;
header("Location: ".$url);
}else if($rowcount2 == 0){ ?>
<script type="text/javascript">
window.onload = function(){
document.getElementById("wel_box").style.display = 'none';
document.getElementById("signup_form_box").style.display = 'none';
document.getElementById("login_bxx").style.display = 'block';
}
</script>
<?php
}
}
$conn->close();
?>
<!DOCTYPE html>
<html>
<head>
<title>blogSpace</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<style>
.box1{
background-image:url("http://pic.51yuansu.com/backgd/cover/00/00/81/5b4d4ae388a50.jpg!/fw/780/quality/90/unsharp/true/compress/true");
background-repeat: no-repeat;
background-size:cover;
height:100vh;
}
.box2{
margin-top:10px;
background-image:url("imgs/oldbooks.jpg");
background-repeat: no-repeat;
background-size:cover;
height:100vh;
}
.box3{
margin-top:10px;
background-image:url("imgs/img_1086253.jpg");
background-repeat: no-repeat;
background-size:cover;
height:100vh;
}
.box4{
margin-top:10px;
background-image:url("imgs/178011925f8d2e9ee3602f47e518-1443303.jpg");
background-repeat: no-repeat;
background-size:cover;
height:100vh;
}
h1{
color:white;
font-size: 80px;
font-family: cursive;
margin-bottom: 20px;
}
.btn_login{
background-color: Transparent;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
border: 2px solid white;
border-radius: 5px;
margin-top: 10px;
float: right;
margin-right: 20px;
}
#sry{
color: red;
}
.btn_login:hover{
border: 2px solid yellow ;
color: yellow;
}
.btn_signup{
background-color: Transparent; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
border: 2px solid white;
border-radius: 5px;
}
.btn_signup:hover{
border: 2px solid yellow ;
color: yellow;
}
#myBtn {
display: none;
position: fixed;
bottom: 20px;
right: 30px;
z-index: 99;
font-size: 18px;
border: none;
outline: none;
background-color: red;
color: white;
cursor: pointer;
padding: 15px;
border-radius: 4px;
}
#myBtn:hover {
background-color: #555;
}
.sign_box{
height: 300px;
width: 500px;
background-color: white;
opacity: 0.85;
border: 2px solid blue;
border-radius: 10px;
}
.login_form_box{
height: 240px;
width: 400px;
background-color: white;
opacity: 0.85;
border: 2px solid green;
border-radius: 10px;
}
</style>
<script>
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 500 || document.documentElement.scrollTop > 500) {
document.getElementById("myBtn").style.display = "block";
} else {
document.getElementById("myBtn").style.display = "none";
}
}
function topFunction() {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}
function func1(){
document.getElementById("wel_box").style.display = 'none';
document.getElementById("signup_form_box").style.display = 'block';
document.getElementById("login_bxx").style.display = 'none';
}
function func2(){
document.getElementById("wel_box").style.display = 'none';
document.getElementById("signup_form_box").style.display = 'none';
document.getElementById("login_bxx").style.display = 'block';
}
</script>
<body>
<button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
<div class="box1">
<button class="btn_login" onclick="func2()">Login</button>
<center style="padding-top: 30vh;">
<div id="wel_box">
<h1>Welcome to blogSpace</h1>
<button class="btn_signup" onclick="func1()">Sign Up</button>
</div>
<div id="signup_form_box" style="display:none;">
<div class="sign_box">
<form method="get">
<div class="form-group" style="margin:20px;">
<label for="user_name">Select user name: <?php if (isset($_GET['user_signup_submit']) and $rowcount > 0) {
echo "<span id='sry'>*sorry! username unavailable, select new name</span>";
} ?> </label>
<input type="text" class="form-control" name="user_name" placeholder="Select user name" pattern=".{4,}" title="user name should contain atleast 4 characters" required/>
</div>
<div class="form-group" style="margin:20px;">
<label for="user_email">Enter email-id:</label>
<input type="email" class="form-control" name="user_email" placeholder="Enter email id" required/>
</div>
<div class="form-group" style="margin:20px;">
<label for="user_psd">Enter Password:</label>
<input type="password" class="form-control" name="user_psd" placeholder="Enter password" required/>
</div>
<input type="submit" name="user_signup_submit" value="Sign Up" class="btn btn-primary" style="width: 60%;font-style: bold;">
</form>
</div>
</div>
<div id="login_bxx" class="login_form_box" style="display: none;">
<form method="post">
<div class="form-group" style="margin:20px;">
<label for="user_name">Enter user name:</label>
<input type="text" class="form-control" name="user_name" placeholder="Enter user name" pattern=".{4,}" title="user name should contain atleast 4 characters" required/>
</div>
<div class="form-group" style="margin:20px;">
<label for="user_pass">Enter Password:</label>
<input type="password" class="form-control" name="user_pass" placeholder="Enter password" required/>
</div>
<input type="submit" name="user_login_submit" value="Login" class="btn btn-success" style="width: 60%;font-style: bold;">
<?php if (isset($_POST['user_login_submit']) and $rowcount2 == 0) {
echo "<br><span id='sry'>*wrong credentials! try again</span>";
} ?>
</form>
</div>
</center>
</div>
<div class="box2">
<center style="padding-top: 30vh;">
<div id="wel_box">
<h1 style="font-size: 100px;">share your thoughths :) </h1>
</div>
</center>
</div>
<div class="box3">
<center style="padding-top: 30vh;">
<div id="wel_box">
<h1 style="font-size: 100px;">explore new worlds!</h1>
</div>
</center>
</div>
<div class="box4">
<center style="padding-top: 30vh;">
<div id="wel_box">
<h1 style="font-size: 100px;">Sign Up to get Started ;)</h1>
</div>
</center>
</div>
</body>
</html>