-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreatemember.php
146 lines (122 loc) · 4.01 KB
/
createmember.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
<?php
require("function.php");
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "gym";
if(count($_POST)>0) {
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$city = $_POST['city'];
$password = $_POST['fname'];
$email = $_POST['email'];
$role = $_POST['role'];
$fees = $_POST['fees'];
if(trim($fname) != '' && trim($lname) != '' && trim($role) != '' && trim($password) != '')
{
$sql = "INSERT INTO login (password,role) VALUES ('$password', '$role')";
}
if ($conn->query($sql) === TRUE) {
//echo "New record created successfully";
$last_id = $conn->insert_id;
//echo $last_id;
$sql="INSERT INTO member (firstname, lastname,loginid, city, email) VALUES ('$fname','$lname','$last_id', '$city', '$email')";
if ($conn->query($sql) === TRUE) {
$last_id = $conn->insert_id;
echo "New record created successfully. Last inserted ID is: " . $last_id;
mysqli_query($conn,"INSERT INTO fees (fees, mid) VALUES ('$fees','$last_id')")or die(mysqli_error($conn));
echo "Successfully added";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
echo "Successfully added";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
//////Select
$conn->close();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Jotorres Login Form</title>
</head>
<body>
<h1>Member Create</h1>
<form method="post" action="createmember.php" >
Name and role are important
<table border="1" >
<tr>
<td><label for="users_email">FName</label></td>
<td><input type="text"
name="fname" id="users_email"></td>
</tr>
<tr>
<td><label for="users_pass">LName</label></td>
<td><input name="lname"
type="text" id="users_pass"></input></td>
</tr>
<tr>
<td><label for="users_email">email</label></td>
<td><input type="text"
name="email" id="users_email"></td>
</tr>
<tr>
<td><label for="users_pass">password</label></td>
<td><input name="password"
type="password" id="password"></input></td>
</tr>
<tr>
<td><label for="users_pass">city</label></td>
<td><input name="city"
type="text" id="city"></input></td>
</tr>
<tr>
<td><label for="users_pass">role</label></td>
<td><input name="role"
type="text" id="role" value="3"></input></td>
</tr>
<td><label for="users_pass">fees</label></td>
<td><input name="fees"
type="text" id="role" value=""></input></td>
</tr>
<td><input type="submit" value="Submit"/>
<td><input type="reset" value="Reset"/>
</table>
</form>
<input type="button" value="back" onclick="window.location.href='admin.php'">
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "gym";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//////Select
$sql = "SELECT * FROM member join login on login.LoginId = member.loginid";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<br><h1>firstname: " . $row["firstname"]. " <br>- lastName: " . $row["lastname"]. "<br>Login Id: " . $row["loginid"]. "<br>Password: " . $row["lastname"]. "</h1>";
}
} else {
echo "0 results";
}
$conn->close();
?>
</body>
</html>