Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <pre><?php
- $db = 'addison8_news';
- mysql_connect("addisonsalzmann.com", "addison8_news", "FU9eHYKu") or die(mysql_error());
- mysql_select_db($db) or die(mysql_error());
- if (isset($_POST['heading']) && isset($_POST['body']))
- mysql_query("INSERT INTO `aTest` (`head`, `body`, `thedate`) VALUES ('" . $_POST['heading'] . "', '" . format($_POST['body']) . "', NOW());");
- if (isset($_POST['clear']))
- mysql_query("TRUNCATE TABLE `aTest`");
- if (isset($_POST['deleterow']))
- mysql_query("DELETE FROM `aTest` ORDER BY `thedate` DESC LIMIT 1");
- echo '<form method="post">' . "\n";
- echo 'Heading:<input type="text" name="heading" />' . "\n";
- echo 'Text:<textarea cols="40" rows="10" type="text" name="body" ></textarea>' . "\n";
- echo '<input type="submit" value="Submit!" />' . "\n";
- echo '<input type="submit" value="Clear All" name="clear" />' . "\n";
- echo '<input type="submit" value="Delete Article" name="deleterow" />' . "\n";
- echo "</form>\n";
- echo '"<br />“<br />”<br />″';
- $result = mysql_query("SELECT * FROM aTest");
- while ($row = mysql_fetch_array($result))
- {
- echo "<h1>" . $row['head'] . "</h1>\n";
- echo "" . $row['body'] . "\n";
- }
- function format($text)
- {
- $text = htmlentities($text, ENT_COMPAT, utf-8);
- $text = preg_replace('/â../', '"', $text);
- $text = preg_replace('/"s/', ''s', $text);
- $text = preg_replace('/([^,][\.|"|!])\r\n([A-Z|"])/m', '$1</p><p>$2', $text);
- return $text;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement