-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_editnewsarticle.php
76 lines (74 loc) · 3.03 KB
/
admin_editnewsarticle.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
<?php include("includes/db.php");?>
<?php include("includes/authcheck.php"); ?>
<?php if ($_SESSION['User']['role'] < 2) header('Location: ' . $baseUrl . 'user.php') ?>
<?php if (!isset($_GET) && !isset($_GET['id']) && !isset($_POST)) header('Location: ' . $baseUrl . 'admin_newsarticle.php') ?>
<?php
if (isset($_GET['id'])) {
$result = mysql_query('SELECT * FROM news WHERE id = "'. $_GET['id'] .'"');
$edit = mysql_fetch_array($result, MYSQL_ASSOC);
}
var_dump($_POST);
if (isset($_POST) && !empty($_POST)) {
$result = mysql_query("
UPDATE news SET title = '" . $_POST['title']. "', main_text = '" . $_POST['main_text']. "'
WHERE news.id = '" . $_POST['id'] . "'");
$error['type'] = 'success';
$error['text'] = 'Succefully added article!';
header('Location: ' . $baseUrl . 'admin_newsarticle.php');
}
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>DigDig - Worlds Diggers and Archeologist club</title>
<link rel="shortcut icon" href="/digdig/img/favico.ico"/>
<!-- Pievienojam skriptus -->
<?php include("includes/scripts.php"); ?>
<!-- END -->
<script type="text/javascript">
var url = "<?php echo 'http://localhost/digdig/'?>";
</script>
</head>
<body class="user-page">
<div id="header-wrap">
<?php include("includes/header.php"); ?>
</div>
<div id="cont-wrapper">
<div id="content">
<h2 class="home-heading main view">
<span>Add news article</span>
</h2>
<div class="leftcol">
<ul class="user-menu-list">
<li><a href="admin_objectlist.php">Admin object list</a></li>
<li class="active"><a href="admin_newsarticle.php">Add news article</a></li>
<?php if ($_SESSION['User']['role'] == 3): ?>
<li><a href="admin_aboutus.php">About us</a></li>
<?php endif ?>
</ul>
</div>
<div class="maincol admin">
<?php if (isset($error)): ?>
<div class="<?php echo $error['type'] ?>"><span><?php echo $error['text'] ?></span></div>
<?php endif; ?>
<form id="addNewsArticle" action="admin_editnewsarticle.php" method="POST">
<div class="input">
<input type="hidden" name="id" value="<?php echo $_GET['id'] ?>">
<input type="text" name="title" class="placeholder" place="Title" value="<?php echo $edit['title'] ?>"/>
</div>
<div class="input">
<textarea class="mceEditorArticle" name="main_text"><?php echo $edit['main_text'] ?></textarea>
</div>
<button type="submit" class="submit">Submit</button>
</form>
</div>
</div>
<br style="clear: both;"/>
</div>
<div id="footer-wrap">
<?php include('includes/footer.php'); ?>
</div>
</body>
</html>