Sie sind auf Seite 1von 7

Config.

php
<?php

$dbhost = "localhost";
$dbuser = "####";
$dbpass = "####";
$dbname = "####";

$db = mysql_connect($dbhost, $dbuser, $dbpass)


or die("<b>Error:</b> Failed to connect to database");

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

$result = mysql_query("SELECT * FROM blog ORDER BY `id` DESC LIMIT 0 , 100");


while($row = mysql_fetch_array($result))
{

$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);

$time = gmdate("M jS Y");


$name = mysql_real_escape_string(htmlentities($name));
$email = mysql_real_escape_string(htmlentities($email));
$message = mysql_real_escape_string(htmlentities($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());

print "Your comment has been added! <a href='index.php'>Return to Index</a>";

if (!isset($name)) {

$idd = mysql_real_escape_string($_GET['idd']);

$existentry = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM blog WHERE id = '$idd'"));


if ($existentry[0] == 1) {

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)) {

$time = gmdate("M jS Y");

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;

CREATE TABLE `comments` (


`id` int(11) NOT NULL auto_increment,
`comment` text collate latin1_general_ci NOT NULL,
`name` text collate latin1_general_ci NOT NULL,
`email` text collate latin1_general_ci NOT NULL,
`entryid` int(11) NOT NULL default '0',
`time` text collate latin1_general_ci NOT NULL,
`temp` int(11) NOT NULL default '0',
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");

$numcomments = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM comments WHERE entryid = '$idd'"));


if ($numcomments[0] == 0) {
echo "There are no comments yet. <a href=\"postcomment.php?idd=$idd\">Post a comment</a>.<br />";
} else {

while($row = mysql_fetch_array($result)) {

echo stripslashes(nl2br("<strong>By:</strong> $row[2] (message #$row[0]) <br />


<strong>Date:</strong> $row[5] <br />
<strong>Message:</strong> $row[1]"));

echo "<li><a href=\"index.php\">Home</a> | <a href=\"postcomment.php?idd=$idd\">Post Comment</a></li>";

?>

<li><a href="index.php">Home</a></li>

Das könnte Ihnen auch gefallen