Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
How to Create a "Comments Form" That Posts Results to Same Page?
Old 06-26-2005, 05:30 PM How to Create a "Comments Form" That Posts Results to Same Page?
Junior Talker

Posts: 4
Trades: 0
Hello everyone,

I hope I am posting under the correct Forum. I am new to PHP code, but I am affluent in regular HTML code. I run an obscure movie review website and would like to be able to have a comment section after each movie review where someone can leave their comment and it gets posted under the review on the same page. I’ve been reading up on PHP for around 4 hours today and can’t seem to find any useful information. Luckily I stumbled upon this forum. So could anyone assist me in doing this? I will give you complete credit for allowing me to have this type of format on the website.

Thank you in advance.

~ Chris

Last edited by Chris Mayo; 06-26-2005 at 05:48 PM..
Chris Mayo is offline
View Public Profile Visit Chris Mayo's homepage!
 
 
Register now for full access!
Old 06-26-2005, 05:49 PM
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
Hey, can you explain what you mean a bit more? From the title, I can only think that you can use the "isset" function.

PHP Code:
<?
if(isset($submit)) {
post the comment
} else {
echo(
"form");
?>
Thats about the only idea I can give you at the moment, see how it goes and get back to me if you need help mate!
feraira is offline
View Public Profile
 
Old 06-26-2005, 06:39 PM
Junior Talker

Posts: 4
Trades: 0
An example of the type of comment form that other review websites have used can be found at the following links:

http://bloody-disgusting.com/review/822

or this:

http://www.twitchfilm.net/archives/002261.html

Or even this comment form which is on a PHP tutorial site, but I still don't have a clue how to go about creating it:

http://www.tipsntutorials.com/tutorials/PHP/50

Thanks,

~ Chris

Last edited by Chris Mayo; 06-26-2005 at 06:54 PM..
Chris Mayo is offline
View Public Profile Visit Chris Mayo's homepage!
 
Old 06-26-2005, 07:10 PM
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
Well, for a start, for the form (if you dont know how), do
HTML Code:
<form action="file" method="how">
Your name: <br><input name="name">
<br><br>
<input name="submit" value="Submit">
</form>
Thats just a straight forward, 1 field form. You can add more of course! I wouldn't know about how to do the rating thing as I haven't attempted one myself yet. Once you have made the form, all you need to do it post it into the database and pull it out and show it.

Remember:
if the form is submitted, add to database
also show the comments posted
if the form isnt submitted, show the form and also all the other things posted
feraira is offline
View Public Profile
 
Old 06-26-2005, 09:00 PM
Junior Talker

Posts: 4
Trades: 0
Here is an example of what I have blindly been messing with which I uploaded to my server:

Example Review Page

What am I missing? What am I doing wrong?

Thanks again.

~ Chris
Chris Mayo is offline
View Public Profile Visit Chris Mayo's homepage!
 
Old 06-26-2005, 09:44 PM
Junior Talker

Posts: 4
Trades: 0
Nevermind. That Example page is terrible. I have no clue what I'm doing...

~ Chris
Chris Mayo is offline
View Public Profile Visit Chris Mayo's homepage!
 
Old 06-27-2005, 05:11 AM
Monkeon's Avatar
Skilled Talker

Posts: 59
Trades: 0
Sounds like you need to learn the basics of PHP before you attempt to do this.
But what you basically need to decide is how you are going to store the comments.
Into a text file or into a MySQL database for instance.

If you're going to be using MySQL, check this tutorial out
http://www.freewebmasterhelp.com/tutorials/phpmysql/1


Form posting with PHP is dead easy.
your form will look something like this

PHP Code:
<form method="POST" action="store_comments.php">
<
input type="text" name="comment">
<
input type="submit" value="Submit">
</
form
and the php script will start off like this

store_comments.php
PHP Code:
<?
// This line grabs the posted info
$your_comment=$_POST['comment'];

// Next comes the MySQL bit

// connect to MySQL
mysql_connect($domain,$user,$password); 
@
mysql_select_db($database) or die( "Unable to select database");

// Write to MySQL
$query "INSERT INTO yourtable VALUES ('','$comment')";
mysql_query($query) or die( "Unable to write to table");

mysql_close();

?>

This is all covered in the tutorial
__________________

Please login or register to view this content. Registration is FREE
FREE Online Dating!
Meet your perfect match online right now!
Monkeon is offline
View Public Profile
 
Old 06-27-2005, 05:20 AM
Monkeon's Avatar
Skilled Talker

Posts: 59
Trades: 0
oops one small mistake there

PHP Code:
$query "INSERT INTO yourtable VALUES ('','$your_comment')"
__________________

Please login or register to view this content. Registration is FREE
FREE Online Dating!
Meet your perfect match online right now!
Monkeon is offline
View Public Profile
 
Closed Thread     « Reply to How to Create a "Comments Form" That Posts Results to Same Page?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.92032 seconds with 12 queries