
Originally Posted by
KyleeIsProzZ
Progress?
You can now write and view news, but not edit them I'm working on it.
EDIT:
Now you can edit and delete news and also edit users.
Only a small Problem with writing the news: Author is always 0
Here's the code if someone can help, just answer please :)
PHP Code:
<?php
if (isset($_POST['submit'])) {
$title = mysql_real_escape_string($_POST['title']);
$shortstory = mysql_real_escape_string($_POST['shortstory']);
$longstory = mysql_real_escape_string($_POST['longstory']);
$image = mysql_real_escape_string($_POST['image']);
$author = mysql_result(mysql_query("SELECT username FROM users WHERE id = '".$_SESSION['user']['id']."' LIMIT 1"), 0);
mysql_query("INSERT INTO cms_news (title, shortstory, longstory, image, author, published) VALUES('$title', '$shortstory', '$longstory', '$image', '$author','" . time() . "')") or die(mysql_error());
echo '<div class="col col-1 msg g">Success! The news article is now posted on {hotelname}!</div>';
};
?>
And the HTML:
PHP Code:
<form id="post_news" name="post_news" method="post" action="">
<input type="text" class="text" style="float: left; width: 50%; margin-right: 1%; margin-bottom: 10px;" name="title" id="title" placeholder="Title..." />
<input type="text" class="text" style="float: left; width: 49%; margin-bottom: 10px;" name="image" id="image" placeholder="top_story_news.png" />
<textarea name="shortstory" class="text" style="margin-bottom: 10px;" id="shortstory" placeholder="Your shortstory text for the post"></textarea>
<textarea name="longstory" class="text mceEditor" rows="5" id="longstory">Your longstory text for the post</textarea>
<input type="submit" name="submit" style="margin-top: 10px;" id="submit" class="btn g" value="Post" />
</form>
And if I didn't said it yet: I'm still learning PHP :'D