Guest User

Untitled

a guest
May 25th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. <?php
  2. ini_set(‘display_errors’,1);
  3. error_reporting(E_ALL|E_STRICT);
  4. if ($_SERVER['REQUEST_METHOD'] == 'POST' && count($_POST) > 0) {
  5.       $hash = sha1(uniqid(mt_rand(), true));
  6. //$sql = 'INSERT INTO pastebin ('
  7. $stmt = $db->prepare("INSERT INTO pastebin (`hash`, `author`, `created`, `pastetext`) VALUES ( :hash, :author, :created, :pastetext ) ");
  8. $stmt->execute(array('hash' => $hash, 'author' => $_POST['authname'], 'created' => time(), 'pastetext' => $_POST['paste']));
  9.  
  10. $sql1 = $stmt->fetchAll(PDO::FETCH_ASSOC);
  11.       if (count($sql1) > 0)
  12.       {
  13.  
  14.               // Redirect the user to the submitted paste.
  15.  
  16.               header('Location: index.php?paste=' . $hash);
  17.  
  18.               exit();
  19.  
  20.       }
  21.  
  22. }
  23. ?>
  24. <!DOCTYPE html>
  25. <html>
  26. <head><title>Sw0rdfish's Pastebin</title></head>
  27. <body>
  28. <form action="index.php" method="post">
  29. <p><input type="text" name="authname" value="Your Name" /></p>
  30. <p><textarea name="paste" rows="15" cols="60"></textarea></p>
  31. <input type="submit"  value="Paste it"/></form>
  32. </body></html>
Add Comment
Please, Sign In to add comment