WordPress.org

Ready to get started?Download WordPress

Forums

Comment form submit button not working (1 post)

  1. nicollette48
    Member
    Posted 7 months ago #

    I am creating my first custom WordPress theme and I am having trouble getting the comment form to work. Everything is displaying properly but when you hit the submit button on the comment form, the page just refreshes and no new comment is submitted.

    My site url is: nicolletteharris.com

    Here is the comment form code in my comments.php file:

    <?php if(comments_open()) : ?>
    	<?php if(get_option('comment_registration') && !$user_ID) : ?>
    		<p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">logged in</a> to post a comment.</p><?php else : ?>
    
    			<?php if($user_ID) : ?>
    
    				<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Log out &raquo;</a></p>
    
    <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    <div class="clearfix comment-textarea">
    							<label for="comment">Comment:</label>
    
    			<textarea tabindex="4" cols="15" rows="10" id="comment" name="comment"></textarea>
    
    <input type="submit" value="Add comment" tabindex="5" id="submit" name="submit">
    
    <input type="hidden" id="comment_post_ID" value="<?php echo $id; ?>" name="comment_post_ID">
    <input type="hidden" value="0" id="comment_parent" name="comment_parent">
    
    <?php comment_id_fields(); ?>
    		<?php do_action('comment_form', $post->ID); ?>
    
    </form>
    <div class="clear"></div>
    
    <?php else : ?>
    
    <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    
    		<div class="cf-label name-label">
    		<label for="author">Your Name: (required)</label>
    			<input type="text" aria-required="true" tabindex="1" size="21" value="<?php echo $comment_author; ?>" id="author" name="author">
    
    </div>
    
    		<div class="cf-label email-label">
    			<label for="email">E-mail (required)</label>
    							<input type="text" aria-required="true" tabindex="2" size="21" value="<?php echo $comment_author_email; ?>" id="email" name="email">
    						</div>
    
    		<div class="cf-label website-label">
    			<label for="url">Website:</label>
    			<input type="text" tabindex="3" size="21" value="<?php echo $comment_author_url; ?>" id="url" name="url">
    						</div>
    
    <div class="clearfix comment-textarea">
    							<label for="comment">Comment:</label>
    
    			<textarea tabindex="4" cols="15" rows="10" id="comment" name="comment"></textarea>
    
    </div>
    
    			<input type="submit" value="Add comment" tabindex="5" id="submit" name="submit">
    <input type="hidden" id="comment_post_ID" value="<?php echo $id; ?>" name="comment_post_ID">
    <input type="hidden" value="0" id="comment_parent" name="comment_parent">
    <?php comment_form(); ?>
    		<?php do_action('comment_form', $post->ID); ?>
    </form>
    <!-- END #comment-form -->
    
    <div class="clear"></div>
    
    <div>
    			<?php endif; ?>
    
    	<?php endif; ?>
    <?php else : ?>
    	<p>The comments are closed.</p>
    <?php endif; ?>

    Please let me know what I am doing wrong. I am new to this but I have a pretty basic understanding of php.

Reply

You must log in to post.

About this Topic