Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include_once("db.php");
  4.  
  5. if(isset($_POST['post']))
  6. {
  7. $title = strip_tags($_POST['title']);
  8. $content = strip_tags($_POST['content']);
  9.  
  10. $title = mysqli_real_escape_string($db, $title);
  11. $content = mysqli_real_escape_string($db, $content);
  12.  
  13. $date = date('l jS \of F Y h:i:s A');
  14.  
  15. $sql = "INSERT into posts (title, content, date) VALUES ('$title', '$content', $date')";
  16.  
  17. if($title == "" || $content == "") {
  18. echo "Por favor, completa el post";
  19. return;
  20. }
  21. mysqli_query($db, $sql);
  22.  
  23. header("Location: index.php");
  24. }
  25. ?>
  26.  
  27. <!DOCTYPE html>
  28. <html>
  29. <head>
  30. <title>Blog - Post</title>
  31. </head>
  32. <body>
  33. <form action="post.php" method="post" enctype="multipart/form-data">
  34. <input placeholder="Titulo" name="title" type="text" autofocus size="48"><br /><br />
  35. <textarea placeholder="Contenido" name="content" rows="20" cols="50"></textarea><br />
  36. <input type="submit" name="post" value="Post">
  37. </form>
  38. </body>
  39. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement