-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
106 lines (99 loc) · 4.89 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
<?php
require('inc/config.php');
session_start();
?>
<?php include('inc/header.php'); ?>
<?php
$sql = "SELECT * FROM users";
$result = mysqli_query($connection, $sql);
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){ //check result exists from the database
$id = $row['user_id'];
$sqlImg = "SELECT * FROM profile_image WHERE user_id='$id'"; //checking if user_id has a profile photo associated
$resultImg = mysqli_query($connection, $sqlImg);
while($rowImg = mysqli_fetch_assoc($resultImg)){
echo "<div>";
if($rowImg['status'] == 1){ //if has photo, fetch photo
echo "<img src='images/uploads/profile".$id.".png'>";
}else{
echo "<img src='images/uploads/profileDefault.png'>"; //otherwise use default photo
}
echo $row['user_id'];
echo "</div>";
}
}
}else{
echo "There are no users yet!";
}
if(isset($_SESSION['id'])){ //checking if the user is logged in
if($_SESSION === 1){
echo "You're logged in as Admin";
}
echo "<form action='upload.php' method='POST' enctype='multipart/form-data'>
<input type='file' name='file'>
<button type='submit' name='upload'>UPLOAD</button>
</form>";//uploads profile photo to uploads folder
} else{ //if not logged in, introduces sign up form
echo "You're not logged in!";
echo "<form action='signup.php' method='POST'>
<div class='form-group'>
<label>*First Name</label>
<input type='text' name='fname' class='form-control'>
</div>
<div class='form-group'>
<label>*Last Name</label>
<input type='text' name='lname' class='form-control'>
</div>
<div class='form-group'>
<label>*Email</label>
<input type='text' name='email' class='form-control'>
</div>
<div class='form-group'>
<label>*Password</label>
<input type='password' name='pword' class='form-control'>
</div>
<div class='form-group'>
<label>* Confirm Password</label>
<input type='password' name='_pword' class='form-control'>
</div>
<div class='form-group'>
<label>Age</label>
<input type='number' name='age' class='form-control'>
</div>
<div class='form-group'>
<label for='style'>Choose favorite skate style:</label>
<select name='style' id='style' default='all'>
<option value='street'>Street</option>
<option value='vert'>Vert</option>
<option value='downhill'>Downhill</option>
<option value='dancing'>Dancing</option>
<option value='freeride'>Freeride</option>
<option value='I love them all!'>You can't expect me to choose just one!</option>
</select>
</div>
<div class='form-group'>
<label>Favorite Trick</label>
<input type='text' name='trick' class='form-control'>
</div>
<div class='form-group'>
<label>Ethereum Public Key</label>
<input type='text' name='eth' class='form-control'>
</div>
<br>
<button type='submit' name='submit' class='btn btn-primary'>Create User Account</button>
</form>";
}
?>
<br><br>
<div class="container">
<p>Login as user!</p>
<form action="login.php" method="POST">
<button type="submit" name="loginbtn">Login</button>
</form>
<br>
<p>Logout as user!</p>
<form action="logout.php" method="POST">
<button type="submit" name="logoutbtn">Logout</button>
</form>
</div>
<?php include('inc/footer.php'); ?>