Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include 'dbconfig.php';
- if($_POST[skapa]) {
- $title = htmlspecialchars($_POST['title']);
- $pretext = htmlspecialchars($_POST['pretext']);
- $text = htmlspecialchars($_POST['text']);
- $img = htmlspecialchars($_POST['img']);
- $date = date("y-n-d");
- $uid = $_SESSION["user_id"];
- $update = mysql_query("UPDATE news SET title = '$title', pretext = '$pretext', text = '$text', date ='$date', uid ='$uid', img = '$img' WHERE id = '$id' LIMIT 1");
- }
- if (isset($_GET['mer'])) {
- $id = $_GET['mer'];
- $sql = mysql_query("
- SELECT *, news.id AS newsid
- FROM news
- JOIN users ON (users.id=news.uid)
- WHERE news.id = '$id' LIMIT 1") or die(mysql_error());
- while($news = mysql_fetch_array($sql))
- echo '<div class="article">
- <div class="story">
- <h4 class="title">'.$news['title'].'</h4>
- '.$news['text'].'
- </div>
- <div class="more">
- <div class="author-image"><img src="'.$news['avatar'].'" alt="Agressions" /></div>
- <span class="post-date">'.$news['name'].'<br /> '.$news['date'].'</span>
- <ul> <li><a href="?mer='.$news['newsid'].'" class="kommentera" title="Läs hela artikeln" style="margin-bottom:10px;">Kommentera</a></li></ul>
- </div>
- </div>';
- }
- if (isset($_GET['news-edit'])) {
- $id = $_GET['news-edit'];
- $sql = mysql_query("
- SELECT *, news.id AS newsid
- FROM news
- JOIN users ON (users.id=news.uid)
- WHERE news.id = '$id' LIMIT 1") or die(mysql_error());
- while($news = mysql_fetch_array($sql))
- echo '<div class="article2">
- <div class="story2">
- <h4 class="title">Ändring av '.$news['title'].'</h4>
- <p><form method="post">Titel: <br /><input name="title" type="text" value="'.$news['title'].'"><br />
- Bild: <br /><input name="img" type="text" value="'.$news['img'].'"><br />
- Inledande Text: <br /><textarea rows="10" cols="80" name="pretext">'.$news['pretext'].'</textarea><br />
- Texten: <br /><textarea rows="10" cols="80" name="text">'.$news['text'].'</textarea></p>
- <input type="submit" value="update" class="login" name="update" />
- </form>
- </div>
- </div>';
- if($_POST[update]) {
- $title = htmlspecialchars($_POST['title']);
- $pretext = htmlspecialchars($_POST['pretext']);
- $text = htmlspecialchars($_POST['text']);
- $img = htmlspecialchars($_POST['img']);
- $date = date("y-n-d");
- $uid = $_SESSION["user_id"];
- $update = mysql_query("UPDATE news SET title = '$title', pretext = '$pretext', text = '$text', date ='$date', uid ='$uid', img = '$img' WHERE id = '$id' LIMIT 1");
- }
- }
- else {
- $sql = mysql_query("
- SELECT *, news.id AS newsid
- FROM news
- JOIN users ON (users.id=news.uid)
- ORDER by news.id desc") or die(mysql_error());
- while($news = mysql_fetch_array($sql))
- echo '<div class="article">
- <div class="story">
- <h4 class="title">'.$news['title'].'</h4>
- '.$news['text'].'
- </div>
- <div class="more">
- <div class="author-image"><img src="'.$news['avatar'].'" alt="Agressions" /></div>
- <span class="post-date">'.$news['name'].'<br /> '.$news['date'].'</span>
- <ul>
- <li><a href="?mer='.$news['newsid'].'" class="kommentera" title="Läs hela artikeln">Läs allt</a></li>
- <li><a href="?mer='.$news['newsid'].'" class="kommentera" title="Läs hela artikeln" style="margin-bottom:10px;">Kommentera</a></li>
- </ul>
- </div>
- </div>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement