Professional Documents
Culture Documents
php
<?php
$dbhost = "localhost";
$dbuser = "####";
$dbpass = "####";
$dbname = "####";
mysql_select_db($dbname, $db)
or die("<b>Error:</b> Failed to select database");
$filename = "ppppp.php";
?>
Index.php
<?php
require "config.php";
?>
<!-- Blog script copyright of addicted one http://yourmomatron.com please leave this line in to help me find users of
my script via google searching. Newest release can always be found at
http://mikeheltonisawesome.com/aoblogger.zip -->
<?php
$id = $row[0];
$numcomments = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM comments WHERE entryid = '$id'"));
echo stripslashes(nl2br("
<h6>$row[3] - $row[1]</h6> $row[2] <br />
<h6>- <a href='viewcomments.php?idd=$id'>Comments: ($numcomments[0])</a> | <a
href='postcomment.php?idd=$id'>Post Comment</a></h6>"));
?>
Postcomment.php
<?php
require "config.php";
?>
<?php
if (isset($name)) {
$name = trim($name);
$email = trim($email);
$message = trim($message);
$namelength = strlen($name);
$messagelength = strlen($message);
if ($namelength < 3) {
$msg = "Your name must be at least 3 characters.";
} elseif ($messagelength < 5) {
$msg = "Your message must be at least 5 characters.";
} elseif ($messagelength > 1000 ) {
$msg = "Your message must be no more than 1,000 characters.";
}
if (isset($msg)) {
echo "$msg";
exit();
} else {
mysql_query("INSERT INTO comments SET comment = '$message', name ='$name', time = '$time', email = '$email',
entryid = '$idd' ") or die(mysql_error());
if (!isset($name)) {
$idd = mysql_real_escape_string($_GET['idd']);
echo "
<form action=\"postcomment.php\" method=\"post\">
<br /><br /><strong>Post new comment</strong>
<h6>Name: </h6><input type=\"text\" name=\"name\" maxlength=\"25\" size=\"40\" /><br /><br />
<h6>Email Address: </h6><input type=\"email\" name=\"mail\" maxlength=\"40\" size=\"40\" /><br /><br />
<h6>Message:</h6> <textarea name=\"message\" rows=\"10\" cols=\"40\" ></textarea>
<input type=\"hidden\" name=\"idd\" value=\"$idd\" /><br /><br />
<input type=\"submit\" value=\"Post Comment\" name=\"send\" class=\"submit\" />
</form>
";
} else {
echo "Invalid blog ID";
}
?>
Ppppp.php
<?php
require "config.php";
?>
<?php
if (isset($message)) {
mysql_query("INSERT INTO blog SET title = '$title', message ='$message', time = '$time'") or die(mysql_error());
print "Your blog has been updated. Go back to the <a href=index.php>index</a> to view it.";
if (!isset($message)) {
echo "
<form action=\"$filename\" method=\"post\">
<br /><br /><strong>Post new entry</strong>
<h6>Title:</h6> <textarea name=\"title\" rows=\"1\" cols=\"80\"></textarea>
<h6>Message:</h6> <textarea name=\"message\" rows=\"10\" cols=\"80\"></textarea><br /><br />
<input type=\"submit\" value=\"Post Entry\" name=\"send\" class=\"submit\" />
</form>";
?>
Sql.sql
CREATE TABLE `blog` (
`id` int(11) NOT NULL auto_increment,
`title` text collate latin1_general_ci NOT NULL,
`message` text collate latin1_general_ci NOT NULL,
`time` text collate latin1_general_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
Viewcomments.php
<?php
require "config.php";
?>
<?php
$idd = mysql_real_escape_string($_GET['idd']);
$result = mysql_query("SELECT * FROM comments WHERE entryid = '$idd' ORDER BY `id` DESC LIMIT 0 , 40");
while($row = mysql_fetch_array($result)) {
?>
<li><a href="index.php">Home</a></li>