-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.php
96 lines (77 loc) · 2.54 KB
/
create.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
<!DOCTYPE html>
<html>
<head>
<title>Create Reminder</title>
</head>
<body>
<?php
if($_POST){
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "Eventreg";
$remmsg = $_POST["remmsg"];
$timing = $_POST["timing"];
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
if (empty($remmsg)){
echo "Reminder Message is empty.Fill in the reminder message\n";
} ?>
<br>
<?php
if (empty($timing)){
echo "The time is empty.Fill in the time\n";
} ?><br>
<div style="margin-top:5%;margin-left:28%;text-align:left;border-radius:5px;width:300px;border :5px solid #e00c2e;height:auto;background-color:rgb(249,249,249);padding:20px;">
<?php
$sql = "INSERT INTO reg(remmsg,timing)
VALUES (\"$remmsg\", \"$timing\")";
if (!(empty($remmsg))&&!(empty($timing))){
if(mysqli_query($conn, $sql)){
echo nl2br("New reminder is created\n\n");
$last_id = $conn->insert_id;
$sql1="SELECT * FROM reg WHERE id=\"$last_id\"";
$result = $conn->query($sql1);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {?>
<b><?php
echo nl2br("Message: ". $row["remmsg"]."\n\n"." Time: ". $row["timing"]);
}
}
else {
echo "0 reminders";
}
?>
</b><form method="POST" action="update.php">
<input type="submit" name="p" value="Update" style="margin:10px;padding: 10px;">
</form>
<form method="POST" action="view.php">
<input type="submit" name="q" value="Delete reminder" style="margin:10px;padding: 10px;">
</form>
</div>
<?php
}
}
else {
echo "Cant create reminder : " . $sql . "<br>" . mysqli_error($conn);
}
}
else { ?>
<div style="margin-top:5%;margin-left:28%;text-align:left;border-radius:5px;width:300px;border :5px solid #e00c2e;height:auto;background-color:rgb(249,249,249);">
<p style="text-align: center;margin-top: 10px;padding-top: 10px;">Register for YD-2018</p><br>
<form method="POST" action="create.php" style="margin:0px;padding: 10px;"><br>
Reminder Message :<br>
<input type="text" name="remmsg" style="margin:0px;padding: 10px;"><br><br>
Time :<br>
<input type="text" name="timing" style="margin:0px;padding: 10px;"><br><br>
<input type="submit" name="create" value=" Create" style="margin:0px;padding: 10px;"><br><br>
</form>
</div>
<?php } ?>
</body>
</html>