-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.php
137 lines (112 loc) · 4.2 KB
/
menu.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
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<?php
session_start();
if(!$_SESSION['auth'])
{
header('Location:login.php');
}
?>
</head>
<body>
<div>
<h1>If your here its mean You successfuly log in to this website</h1>
<a href="logout.php">LogOut</a>
<div style="margin:50px; ">
<form method="post" action="inftodb.php"
style="border: 3px solid; width: 250px; padding: 20px;">
<h2>Insert Story</h2>
<table width="60%">
<tr>
<td><input type="text" name="name" placeholder="Youre Name" ></td>
</tr>
<tr>
<td><input type="text" name="headline" placeholder="Topic"></td>
</tr>
<tr>
<td><textarea name="story" placeholder="Story"></textarea></td>
</tr>
<tr>
<td><input type="submit" name="add"></td>
</tr>
</table>
</form>
</div>
<!-- ================================================================================ -->
<!-- +++++++++++++++++++++++++++++++ REMOVE STORY BEGIN++++++++++++++++++++++++++++++ -->
<!-- ================================================================================ -->
<div style="margin:50px; border: 3px solid; padding: 20px; width: 250px;">
<?php
if(isset($_POST[removeNews])){
$connect = mysqli_connect("localhost", "root", "root", "neww");
$remove = "DELETE FROM news WHERE id='$_POST[removeNews]'";
$resultRem= mysqli_query($connect, $remove);
if ($resultRem) {
echo "Successfuly removed";
}else
{
echo "Erorr removing";
}
}
?>
<form action="menu.php" method="POST">
<h2>Remove Story</h2>
<input style="width:190px;" type="text" name="removeNews" placeholder="To Remove Story Write here ID">
<input type="submit" name="removeNews" >
</form>
</div>
<!-- ================================================================================= -->
<!-- +++++++++++++++++++++++++++++++ REMOVE STORY END+++++++++++++++++++++++++++++++++ -->
<!-- ================================================================================= -->
<!-- ================================================================================= -->
<!-- ++++++++++++++++++++++++++++++ UPDATE STORY BEGIN ++++++++++++++++++++++++++++++++-->
<!-- ================================================================================= -->
<div style="margin:50px; padding: 20px; border: 3px solid; width: 400px;">
<?php
if(isset($_POST[update]))
{
$connect = mysqli_connect("localhost", "root", "root", "neww");
$update = "UPDATE news SET story='$_POST[updateStory]' WHERE id='$_POST[updateID]'";
$resultUp = mysqli_query($connect, $update);
if ($resultUp){
echo "Succes update story on ID:".$_POST[updateID];
}else { echo "Error"; }
}
?>
<form action="menu.php" method="POST">
<h2>Update Story</h2>
<input type="text" name="updateID" placeholder="Write ID">
<input type="text" name="updateStory" placeholder="Update story">
<input type="submit" name="update">
</form>
</div>
<!-- ================================================================================= -->
<!--+++++++++++++++++++++++++++++++ UPDATE STORY END +++++++++++++++++++++++++++++++++-->
<!-- ================================================================================= -->
<!-- ================================================================================ -->
<!-- +++++++++++++++++++++++++++++++ SHOW STORY BEGIN++++++++++++++++++++++++++++++ -->
<!-- ================================================================================ -->
<div style="border: 3px groove; width: 700px; padding: 20px;">
<?php
$connect = mysqli_connect("localhost", "root", "root", "neww");
if ($connect->connect_error) {
die("Connection failed: " . $connect->connect_error); }
$show = "SELECT id,story FROM news";
$re = mysqli_query($connect,$show);
while($row=mysqli_fetch_assoc($re))
{
echo "ID: ".$row[id].") Story: ".$row[story]."<br>";
}
?>
</div>
<div>
<!-- ================================================================================ -->
<!-- +++++++++++++++++++++++++++++++ SHOW STORY END++++++++++++++++++++++++++++++ -->
<!-- ================================================================================ -->
</div>
</div>
</div>
</body>
</html>