Wizet
New Member
- Messages
- 644
- Reaction score
- 0
- Points
- 0
I just need someone to help me finish a commenting box script. The comment box can be found on the "new additions" link. http://mfhome.us.to
<!-- HTML codes by Quackit.com -->
<form action="/html/tags/html_form_tag_action.cfm" method="post">
Comments:<br />
<textarea name="comments" id="comments">
Hey... say something!
</textarea><br />
<input type="submit" value="Submit" />
</form>
<p style="font-family:verdana,arial,sans-serif;font-size:10px;"><a href="http://www.quackit.com/html/codes/comment_box_code.cfm">Comment Box</a></p>
<?php
mysql_connect("localhost", "cpuser_dbuser", "password"); //practice placing your db information in a non web-accessible directory
mysql_select_db("cpuser_dbname"); // such as the parent directory of public_html (your home directory)
if ($_POST['add_comment']) {
if (!empty($_POST['comments']) && !empty($_POST['email']) && !empty($_POST['name'])) {
$comments = mysql_real_escape_string($_POST['comments']);
$email = mysql_real_escape_string($_POST['email']);
$name = mysql_real_escape_string($_POST['name']);
$time = time();
$result = mysql_query("INSERT INTO comments (id, comments, email, name, time) VALUES(NULL, $comments, $email, $name, $time)");
if ($result) {
echo 'Comment Posted<br /><br />
Click <a href="http://forums.x10hosting.com/marketplace/?">here</a> to return';
}
} else {
echo 'You Forgot a Field<br /><br />
Click <a href="javascript:history.go(-1)">here</a> to return';
}
} else {
?>
<form action="?submit" method="post">
Comments:<br />
<textarea name="comments">
Hey... say something!
</textarea><br />
Name: <input name="name" type="text" /><br />
Email (hidden): <input name="email" type="text" /><br /><br />
<input type="submit" value="Submit" name="add_comment" />
</form>
<?php
}
?>
CREATE TABLE `comments` (
`id` INT( 3 ) NOT NULL AUTO_INCREMENT ,
`comments` VARCHAR( 255 ) NOT NULL ,
`email` VARCHAR( 255 ) NOT NULL ,
`name` VARCHAR( 255 ) NOT NULL ,
`time` INT( 10 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM
[PHP]<?php
mysql_connect("localhost", "cpuser_dbuser", "password"); //practice placing your db information in a non web-accessible directory
mysql_select_db("cpuser_dbname"); // such as the parent directory of public_html (your home directory)
if ($_POST['add_comment']) {
if (!empty($_POST['comments']) && !empty($_POST['email']) && !empty($_POST['name'])) {
$comments = mysql_real_escape_string($_POST['comments']);
$email = mysql_real_escape_string($_POST['email']);
$name = mysql_real_escape_string($_POST['name']);
$time = time();
$result = mysql_query("INSERT INTO comments (id, comments, email, name, time) VALUES(NULL, $comments, $email, $name, $time)");
if ($result) {
echo 'Comment Posted<br /><br />
Click <a href="http://forums.x10hosting.com/marketplace/?">here</a> to return';
}
} else {
echo 'You Forgot a Field<br /><br />
Click <a href="javascript:history.go(-1)">here</a> to return';
}
} else {
?>
<form action="?submit" method="post">
Comments:<br />
<textarea name="comments">
Hey... say something!
</textarea><br />
Name: <input name="name" type="text" /><br />
Email (hidden): <input name="email" type="text" /><br /><br />
<input type="submit" value="Submit" name="add_comment" />
</form>
<?php
}
?>[/PHP]
<?php
mysql_connect("localhost", "cpuser_dbuser", "password"); //practice placing your db information in a non web-accessible directory
mysql_select_db("cpuser_dbname"); // such as the parent directory of public_html (your home directory)
if ($_POST['add_comment']) {
if (!empty($_POST['comments']) && !empty($_POST['email']) && !empty($_POST['name'])) {
$comments = mysql_real_escape_string($_POST['comments']);
$email = mysql_real_escape_string($_POST['email']);
$name = mysql_real_escape_string($_POST['name']);
$time = time();
$result = mysql_query("INSERT INTO comments (id, comments, email, name, time) VALUES(NULL, $comments, $email, $name, $time)");
if ($result) {
echo 'Comment Posted<br /><br />
Click <a href="http://forums.x10hosting.com/marketplace/?">here</a> to return';
}
} else {
echo 'You Forgot a Field<br /><br />
Click <a href="javascript:history.go(-1)">here</a> to return';
}
} else {
$result = mysql_query("SELECT comments, name, time FROM comments ORDER BY id DESC LIMIT 20");
while ($result = mysql_fetch_assoc($result)) {
$comment = str_replace("\n", '<br />', $result['comments']);
$name = $result['name'];
$time_offset = (-5*3600); // If your target base is located in the east-coast (EST -5), then leave alone. If it's different, then modify -5 to the proper offset
$date = date('M j, Y g:i a', ($result['time']+$time_offset)); // For date format information, see http://www.php.net/date
echo '<p>'.$comment.'<br /><strong>By: '.$name.' on '.$date.'</strong></p>';
}
?>
<form action="?submit" method="post">
Comments:<br />
<textarea name="comments">
Hey... say something!
</textarea><br />
Name: <input name="name" type="text" /><br />
Email (hidden): <input name="email" type="text" /><br /><br />
<input type="submit" value="Submit" name="add_comment" />
</form>
<?php
}
?>
mysql_connect("localhost", "cpuser_dbuser", "password"); //practice placing your db information in a non web-accessible directory
mysql_select_db("cpuser_dbname"); // such as the parent directory of public_html (your home directory)
click on the db u created, then click on SQL on the top and paste the code i posted before in the textbox:information_schema (17)
cpuser_dbuser (0)
xPlozion, have you been paid for your services?