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
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
Come and join us @ The Fanciest Windows Forum around!
Do you have any code to work off of or is it all being built from the ground up? I can build one for you if you need it built.
Also, do you have a defined table for the comments? What other features do you want? Do you want an email address to accompany every post, a time stamp (kinda a given though). I can build a simple basic one real quick if you want basics...
PS. I've noticed that you switched from SMF to phpBB. Have you ever heard of Pun/FluxBB? it's very easy to integrate, and an excellent piece of forum software. I'm using it on my website, and it's very, I repeat, very easy to modify, given the fact you've got PHP experience (which unfortunately, by the looks of it, not much...)
That is the code. And yes i Don't have any experience in php whatsoever.HTML Code:<!-- 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>
Come and join us @ The Fanciest Windows Forum around!
Sorry about the late response. I didn't want to leave XP because of Google Chrome, and linux is where I develop everything.
Try this:I'll be back with the SQL code for a one click db install ;).PHP Code:<?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
}
?>
[EDIT]
Back, just go to the database you want this table in, click SQL on the top nav, and copy/paste this in the box
If something doesn't work right, let me know. I haven't tested it, although I should, but I'm confident in the codeCode: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
-xP
Last edited by xPlozion; 09-03-2008 at 08:45 PM. Reason: there's your mysql code
[quote by xploxzon]Sorry about the late response. I didn't want to leave XP because of Google Chrome, and linux is where I develop everything.
Try this:
PHP Code:
[/quote]HTML Code:[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]
Where do I put this?
Last edited by Wizet; 09-03-2008 at 09:37 PM.
Come and join us @ The Fanciest Windows Forum around!
the php code you would put in the page that you want to have the comment box on. I don't know where you want the comments results at, but I'll do that tomorrow, as it's late, and i have to get up early tomorrow.
-xP
All in the same file... - your comment form/insert page.
This is a good, basic script that can be inserted anywhere in the "body" of the page
i.e. after
<body>
and before
</body>
The first two lines of the script are connection parameters.
The remaining 1st half asks "if something has been put in the form, then insert it into the database. If nothing has been submitted, go to the next half of the page."
The middle bit checks that all fields have been completed and gives you a warning if they haven't.
The last half of the script produces the form if nothing has been submitted (by default). This is the bit that you will actually see in your page.
working off of the original code i posted above, this also displays comments above the comment box
PHP Code:<?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
}
?>
So you just put the php code in the top of the page right? Im'a test it out first. Maybe it's the way I put it but the code looks all messy with errors and that stuff.
Last edited by Wizet; 09-04-2008 at 04:04 PM.
Come and join us @ The Fanciest Windows Forum around!
OK, looking at your page, your error is that the page is an htm file, when it needs to be a php file. Rename new_additions.htm to new_additions.php . also, put the proper values in the top 2 lines where there's mysql_connect and mysql_select_db.
Last edited by xPlozion; 09-04-2008 at 04:56 PM.