Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <pre><?php
  2. $db = 'addison8_news';
  3. mysql_connect("addisonsalzmann.com", "addison8_news", "FU9eHYKu") or die(mysql_error());
  4. mysql_select_db($db) or die(mysql_error());
  5.  
  6. if (isset($_POST['heading']) && isset($_POST['body']))
  7. mysql_query("INSERT INTO `aTest` (`head`, `body`, `thedate`) VALUES ('" . $_POST['heading'] . "', '" . format($_POST['body']) . "', NOW());");
  8. if (isset($_POST['clear']))
  9. mysql_query("TRUNCATE TABLE `aTest`");
  10. if (isset($_POST['deleterow']))
  11. mysql_query("DELETE FROM `aTest` ORDER BY `thedate` DESC LIMIT 1");
  12.  
  13.  
  14. echo '<form method="post">' . "\n";
  15. echo 'Heading:<input type="text" name="heading" />' . "\n";
  16. echo 'Text:<textarea cols="40" rows="10" type="text" name="body" ></textarea>' . "\n";
  17. echo '<input type="submit" value="Submit!" />' . "\n";
  18. echo '<input type="submit" value="Clear All" name="clear" />' . "\n";
  19. echo '<input type="submit" value="Delete Article" name="deleterow" />' . "\n";
  20. echo "</form>\n";
  21. echo '"<br />&ldquo;<br />&rdquo;<br />&Prime;';
  22.  
  23. $result = mysql_query("SELECT * FROM aTest");
  24. while ($row = mysql_fetch_array($result))
  25. {
  26. echo "<h1>" . $row['head'] . "</h1>\n";
  27. echo "" . $row['body'] . "\n";
  28. }
  29.  
  30. function format($text)
  31. {
  32. $text = htmlentities($text, ENT_COMPAT, utf-8);
  33. $text = preg_replace('/&acirc;../', '"', $text);
  34. $text = preg_replace('/"s/', '&#39;s', $text);
  35. $text = preg_replace('/([^,][\.|"|!])\r\n([A-Z|"])/m', '$1</p><p>$2', $text);
  36. return $text;
  37. }
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement