-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
147 lines (96 loc) · 3.53 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
<!DOCTYPE html>
<html>
<head>
<title>Fitness App. Create Exercises</title>
<style>
.container {
margin-top: 80px;
}
.containersignin{
margin-bottom: 200px;
}
body {
background-color: pink;
}
</style>
</head>
<body>
<div class="container">
<!-- Create Form for Registration -->
<form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
<!-- Action on the same page -->
<center>
<img src="image/image1.jpg">
<h1>Fitness Membership Register Form</h1>
<p>Please fill in this form to create an account.</p>
<hr>
<label for="username"><b>Name:</b></label>
<input type="text" placeholder="Enter your name" name="name" required><br><br>
<label for="surname"><b>Surname:</b></label>
<input type="text" placeholder="Enter your surname" name="surname" required><br><br>
<label for="surname"><b>Username:</b></label>
<input type="text" placeholder="Enter your username" name="user_name" required><br><br>
<label for="psw"><b>Password:</b></label>
<input type="password" placeholder="Enter Password" name="pass" required><br><br>
<label for="length"><b>Length:</b></label>
<input type="text" id="length" name="length" placeholder="Enter your lenght"><br><br>
<label for="weight"><b>Weight:</b></label>
<input type="text" id="weight" name="weight" placeholder="Enter your weight"><br><br>
<label for="sex"><b>Sex:</b></label>
<select id="sex" name="sex">
<option value="male">Male</option>
<option value="female">Female</option>
</select> <br><br>
<label for="age"><b>Age:</b></label>
<input type="text" id="age" name="age" placeholder="Enter your age"><br><br>
<label for="body"><b>Choose your desired body shape:</b></label>
<select id="body" name="body">
<option value="Weight loss">Weight loss</option>
<option value="Body building">Body building</option>
<option value="Maintaining body mass index">Maintaining body mass index</option>
</select> <br>
<hr>
<button type="submit" class="registerbtn">Register</button>
</div>
<div class="containersignin"><center>
<?php
// Information about Host(Server)
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "FitnessAccounts";
// Create Connection
$conn = new mysqli($servername,$username,$password,$dbname);
// Check Connection
if ($conn->connect_error) {
die("Connection Failed: " . $conn->connect_error);
}
// Get Data from Form through REQUEST_METHOD
// Post value must be equal to input's name value
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$name=$_POST['name'];
$surname=$_POST['surname'];
$user_name=$_POST['user_name'];
$pass=$_POST['pass'];
$length = $_POST['length'];
$weight = $_POST['weight'];
$sex = $_POST['sex'];
$age = $_POST['age'];
$body = $_POST['body'];
// SQL command is upload to AccountsRegister table and data is mapped to table values.
$sql = "INSERT INTO AccountsRegister (id, name, surname, username, password, length, weight, sex, age, body) VALUES (NULL,'$name', '$surname', '$user_name','$pass', '$length', '$weight', '$sex', '$age', '$body')";
// If the Registration complete, This message output on the webpage.
if (mysqli_query($conn, $sql)) {
echo "Account Created Successfully!";
}
}
?>
<p>Already have an account? <a href="sign-in.php">Sign in</a>.</p>
<p><a href="admin.php">Login Admin</a></p>
</center>
</div>
</form>
</center>
</body>
</html>