boleknowak

Untitled

Jan 5th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <?php
  2. include_once("db.php");
  3.  
  4. if(isset($POST['submit'])){
  5. $title = strip_tags($_POST['title']);
  6. $content = strip_tags($_POST['content']);
  7.  
  8. $title2 = mysqli_real_escape_string($db, $title);
  9. $content2 = mysqli_real_escape_string($db, $content);
  10.  
  11. $date = date('l jS \of F Y h:i:s A');
  12.  
  13. $sql = "INSERT INTO blog_posts(title, content, date) VALUES ('$title2', '$content2', '$date')";
  14.  
  15. if($title == "" || $content == ""){
  16. echo "Wypełnij pola!";
  17. }
  18.  
  19. mysqli_query($db, $sql);
  20.  
  21. header("Location: index.php");
  22. }
  23. ?>
  24.  
  25. <!DOCTYPE html>
  26. <html>
  27. <head>
  28. <title>post</title>
  29. </head>
  30.  
  31. <body>
  32. <form action="post.php" method="post">
  33. <input placeholder="Tytuł" name="title" type="text" autofocus size="48"><br /><br />
  34. <textarea placeholder="Treść" name="content" rows="20" cols="50"></textarea><br />
  35. <input name="submit" type="submit" value="Dodaj posta">
  36. </body>
  37. </html>
Advertisement
Add Comment
Please, Sign In to add comment