PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 1st, 2013, 01:28 PM
tunabicycle tunabicycle is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 2 tunabicycle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 17 m 45 sec
Reputation Power: 0
New Member - Comment FORM - comments.php

Hi, I need the comments for my blog to work. They will be on the same page and automatically post. I searched the forum and tried a tutorial (can't post url link) , but still no bueno!

here is the current html of the form:



<div id="respond">

<div class="cancel-comment-reply"><a rel="nofollow" id="cancel-comment-reply-link" href="#respond" style="display:none;">Cancel reply</a></div>
<form action="comments.php" method="post" id="commentform">
<h3 class="heading">LEAVE A REPLY</h3>
<input type="text" name="comments" id="author" value="" tabindex="1" />
<label for="author">Name <small>*</small></label><br/>

<input type="text" name="email" id="email" value="" tabindex="2" />
<label for="email">Email <small>*</small> <span>(not published)</span></label><br/>

<input type="text" name="url" id="url" value="" tabindex="3" />
<label for="url">Website</label>

<textarea name="comment" id="comment" tabindex="4"></textarea>

<p><input name="submit" type="submit" id="submit" tabindex="5" value="Post" /></p>

<input type='hidden' name='comment_post_ID' value='' id='comment_post_ID' />
<input type='hidden' name='comment_parent' id='comment_parent' value='0' />
</form>
</div>
<div class="clearfix"></div>

and here is the php i added as per the guys' instructions:

<?php
$hFile = fopen( "comments.txt", "a+" );
fwrite( $hFile, "$comments" );
fclose( $hFile );
?>


I need the comments to post automatically on the page once the user presses send. Extreme novice! Sorry.


I appreciate anyone's help on this. Thanks for your time.

Reply With Quote
  #2  
Old February 2nd, 2013, 10:20 AM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Dev Shed God 7th Plane (8000 - 8499 posts)
 
Join Date: Dec 2004
Posts: 8,057 E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 1 Day 6 h 47 sec
Reputation Power: 7104
Writing a comment system is a simple but non-trivial feature. It's actually not a bad starting point at all for a new PHP programmer.

However, the PHP code you have so far will not work. It looks like it's really outdated.

There are you things you need to do: first you need to program a script to store the submitted comments somewhere, then you need to program a script to retrieve and display the stored comments.

The most appropriate place to store the comments is in a database. An alternative is to store them in a file, like the code "the guy" gave you is trying to do. Storing the comments in a file is easier to understand for a beginner, but worse in pretty much every other way; particularly if you want to have additional fields like email.

You should start by finding a basic tutorial on PHP. It will teach you the basic syntax of PHP and how to use $_POST and $_GET to retrieve submitted form values. Once you understand the basics, you can find a tutorial on SQL for MySQL and on PHP+MySQL which will teach you how to use a database.
__________________
PHP FAQ
How to program a basic, secure login system using PHP
Connect with me on LinkedIn


Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
  #3  
Old February 4th, 2013, 10:29 AM
tunabicycle tunabicycle is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 2 tunabicycle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 17 m 45 sec
Reputation Power: 0
thank you!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > New Member - Comment FORM - comments.php

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap