-
Notifications
You must be signed in to change notification settings - Fork 0
/
insertf.php
168 lines (129 loc) · 4.4 KB
/
insertf.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
<!DOCTYPE html>
<html>
<head>
<title>Insert Page page</title>
</head>
<style>
.container
{
position: absolute;
top:50%;
left:50%;
transform: translate(-50%,-50%);
display: flex;
flex-direction: column;
align-items: center;
background-color: #8dc8c9;
padding: 50px;
}
.btn
{
background-color: #5184a0; /* Green */
border: none;
color: white;
padding: 15px 16px;
text-align: center;
text-decoration: none;
font-size: 16px;
border-radius: 12px;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
</style>
<body background="bg.jpg">
<center>
<?php
// servername => localhost
// username => root
// password => empty
// database name => staff
$conn = mysqli_connect("localhost", "root", "", "blood_bank");
// Check connection
if($conn === false)
{
die("ERROR: Could not connect. "
. mysqli_connect_error());
}
// Taking all 5 values from the form data(input)
$rn = $_REQUEST['regno'];
$full_name = $_REQUEST['name'];
$bloodgroup = $_REQUEST['bloodgroup'];
$phone = $_REQUEST['phone'];
$email = $_REQUEST['email'];
$city = $_REQUEST['city'];
$fn=strtoupper($full_name);
$registerno=strtoupper($rn);
$c=strtoupper($city);
// Performing insert query execution
// here our table name is college
$sql = "INSERT INTO students VALUES ('$registerno','$fn','$bloodgroup','$phone','$email','$c')";
try
{
if(mysqli_query($conn, $sql))
{
echo "<div class='container'>";
echo "<h3>REGISTRATION SUCCESSFULL<h3>";
echo ("\n\n\n");
echo "<table border='1'>";
echo "<tr>";
echo "<td>" . "REGISTER NUMBER " . "</td>";
echo "<td>" .$registerno. "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>" ." NAME " . "</td>";
echo "<td>" .$fn. "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>" . "BLOOD GROUP ". "</td>";
echo "<td>" .$bloodgroup. "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>" ." PHONE NUMBER " . "</td>";
echo "<td>" .$phone. "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>" . "EMAIL ID " . "</td>";
echo "<td>" .$email. "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>" . "CITY" . "</td>";
echo "<td>" .$c. "</td>";
echo "</tr>";
echo "</div>";
echo "</table>";
}
$to_email ="$email" ;
$subject = "REGISTRATION SUCCESSFULL";
$body = "Thank you for registering in bloodbank";
$headers = "From: xxxx@gmail.com";
if (mail($to_email, $subject, $body, $headers))
{
echo "<br>";
echo "CONFIRMATION MAIL SENT SUCCESSFULY ";
echo "<br>";
echo "<br>";
echo " ***THANK YOU***";
}
else
{
echo "Email sending failed...";
}
//echo "</div>";
// . " Please browse your localhost php my admin"
//. " to view the updated data</h3>";
//echo nl2br("\n REGISTER NUMBER :$registerno\n NAME :$full_name\n "
// . " BLOOD GROUP : $bloodgroup\n PHONE NO : $phone\n EMAIL : $email \n CITY : $city");
}
catch(Exception $e)
{
echo " <h2>
<b>YOUR REGISTER NUMBER ALREADY EXISTS</b></h4>";
echo "<br>";
echo "PLEASE ENTER VAID DETAILS";
}
// Close connection
mysqli_close($conn);
?>
<p><form action="index.html"><button class="btn"> EXIT</button></form></p>
</center>
</body>
</html>