Jump to content

Post Comment Script


nilrac

Recommended Posts

Hi there, sorry to bother, I did a quick search for the answers I need, but couldn't see anything. I probably need to look better.

Basically, I want to make one of my websites more interactive. I think I can do this with PHP. I want my site visitors to have the ability to post comments/feedback on reviews and interviews on my site. I want these comments to appear on the page, under the review/interview. Would work in a similar way to a guestbook, I believe. I think you get the idea.

Now, my knowledge of PHP is near nothing, very, very basic. I did put an email form on a test page using PHP, to send feedback via email. However, I'd prefer for the comments/feedback to be displayed on the page. Is there a script/method around that can help a novice like me? Preferrably I'd like to see up a registration scheme, so only people who are registered can post feedback on articles/reviews/interviews and so on. Which makes the task even more complicated to me.

I realise I will need to set up a database for this, again not my forte. So any instructions about achieving this would be greatly appreciated. It's like that saying, easy when you know how, but hard when you don't!

I've actually spent alot of time googling this, but came up with nothing. I did, though, find this, by the looks of it, excellent forum. Thanks for reading,
-Rich
Link to comment
https://forums.phpfreaks.com/topic/26473-post-comment-script/
Share on other sites

Search for "php guestbook" in google.  There are thousands of examples.

Here's about 50 on this site alone:
[url=http://www.phpfreaks.com/scripts/Guestbooks/4.php]http://www.phpfreaks.com/scripts/Guestbooks/4.php[/url]
[url=http://www.phpfreaks.com/quickcode/Complete-Guestbook/349.php]http://www.phpfreaks.com/quickcode/Complete-Guestbook/349.php[/url]

-pnj
Link to comment
https://forums.phpfreaks.com/topic/26473-post-comment-script/#findComment-121473
Share on other sites

Hey Andy,
  I tried to implement that script, but something is wrong. I am guessing with the database. That said, there is no sign -at all- of the comment feature on the page even though I added the code for it and uploaded all the php files. Not even a comment feature thar doesn't work, if you know what I mean. Any ideas? Common pitfalls?

Thanks for the responses btw. It's appreciated.
-Rich
Link to comment
https://forums.phpfreaks.com/topic/26473-post-comment-script/#findComment-121715
Share on other sites

This is actually quite simple to do nilrac, nothing but a simple form and a little bit of PHP. First thing is first.. make a form with the associated fields you need. Like the Name, Title, and the Description or Post of what is said. Next would be to post ALL the information into your database [assuming you have one that is] with a submit button on the form. Next all you need to do is print the information into the page you'd like it to be displayed in. Very quickly I'll write something for you, to help you better understand the situation.

[code]<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Tutorial</title>
</head>

<body>
<form name="form1" method="post" action="post.php">
  Name:
  <label>
  <input name="name" type="text" id="name">
  </label>
  <br>
Title:
<label>
<input name="title" type="text" id="title">
</label>
<br>
<label>
Post:
<textarea name="post" id="post"></textarea>
</label>
<br>
<label>
<input name="submit" type="submit" id="submit" value="Submit">
</label>
</form>
</body>
</html>[/code]

This will be your HTML code that will just basically tell which is what, now to post the data that was entered into the database. This will contain that you make another page named post.php or whatever it is you'd like.

[code]<?php
$name=$_POST['name'];
$title=$_POST['title'];
$post=$_POST['post'];

mysql_query("INSERT into reviews (name, title, post) VALUES ('$name', '$title', '$post')");

print "Your review has been posted.";
?>[/code]

Now that, that's complete, just put the variables in on your reviews page where everyone elses displays, and it'll work just fine. Here's a small example.

[code]<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Tutorial</title>
</head>

<body>
<?php

$postinfo=mysql_query("SELECT * FROM reviews");

print "<table><tr><td>Reviews</td></tr>
<tr><td>Name: $postinfo[name]</td></tr>
<tr><td>Title: $postinfo[title]</td></tr>
<tr><td>Post: $postinfo[post]</td></tr>
</table>";

?>
</body>
</html>
[/code]

Of course to display all of them you'll need to use a while loop, but that's the next step, getting down the basics is the most essential part of making it happen.
Link to comment
https://forums.phpfreaks.com/topic/26473-post-comment-script/#findComment-121730
Share on other sites

thanks for your help, mate. appreciated.
i followed those instructions, and as far as i know i've done everything correct -so far- except connect the database properly or add the appropriate data. how should i approach this aspect?

(my site control panel allows me to create SQL databases, and edit e.t.c. with PHPadmin).
Link to comment
https://forums.phpfreaks.com/topic/26473-post-comment-script/#findComment-121889
Share on other sites

[quote author=nilrac link=topic=114163.msg465215#msg465215 date=1163034697]
thanks for your help, mate. appreciated.
i followed those instructions, and as far as i know i've done everything correct -so far- except connect the database properly or add the appropriate data. how should i approach this aspect?

(my site control panel allows me to create SQL databases, and edit e.t.c. with PHPadmin).
[/quote]

Your site control panel ought to give you a 'connection string' so you know how to connect to the database server, select a database for use, etc.  If in doubt, pretty well any of the scripts you could find here will include relevant code to make those connections. Important tip: always [b]write down[/b] any database passwords, usernames, etc. that you choose. You will remember them for a few minutes; you will forget them next week.
Link to comment
https://forums.phpfreaks.com/topic/26473-post-comment-script/#findComment-121899
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.