+ Reply to Thread
Results 1 to 3 of 3

Thread: PHP Comment Script

  1. #1
    techgeek1499 is offline x10Hosting Member techgeek1499 is an unknown quantity at this point
    Join Date
    Sep 2009
    Location
    Ohio
    Posts
    18

    PHP Comment Script

    I have a test page: http://www.techcorner.pcriot.com/test/reviews.php

    The gray box area thing isn't centered in the page and I am wondering how to do that.

    This isn't the full code because it's long and this is where it would be if anything.

    Code:
    <style>
    /*COMMENTS
    *------------------------------------*/
    
    .postedby {
    	text-align: Center;
    	}
    	
    h3.formtitle {
    	margin : 0px 0px 0px 12px;
    	border-bottom: 1px dotted #ccc;
    	padding-bottom: 8px;
    	}
    
    .commentbody {
    	border-top: 1px dotted #ccc;
    	}
    	
    /*gray box*/
    .submitcomment, #submitcomment, #currentcomments, #rating, .textad {
    	background-color: #F5F5F5;
    	border: 1px dotted #ccc;
    	width: 550px;
    	}
    
    
    /*FORMS
    *------------------------------------*/
    
    .form {
    	font-size: 100%;
    	background-color: #FAFAFA;
    	border: solid 1px #C6C6C6;
    	padding: 2px;
    	}
    
    .formtext {
    	background-color: #FAFAFA;
    	border: solid 1px #C6C6C6;
    	padding: 2px;
    	border-bottom: 1px dotted #ccc
    	}
    
    .form:hover, .formtext:hover {
    	background: white;
    	}
    	
    .form:focus, .formtext:focus {
    	background: white;
    	border: solid 1px #000000;
    	}
    	
    .submit {
    	background-color: #D3D3D3;
    	border: solid 1px #C6C6C6;
    	border-right:  solid 1px #9A9A9A;
    	border-bottom:  solid 1px #9A9A9A;
    	}
    	
    .submit:hover, .submit:focus {
    	background: #EDEDED;
    	}
    	</style>
    
    	
    	";
    //fetch all comments from database where the tutorial number is the one you are asking for
    	$commentquery = mysql_query("SELECT * FROM comments WHERE tutorialid='$tutid' ORDER BY date DESC") or die(mysql_error());
    //find the number of comments
    	$commentNum = mysql_num_rows($commentquery);
    //create a headline
    	echo "<div id=\"currentcomments\" class=\"submitcomment\"><h3 class=\"formtitle\">Current Comments</h3>\n";
    	echo $commentNum . " comments so far (<a href=\"#post\">post your own</a>)\n";
    //for each comment in the database in the right category number...
    	while($commentrow = mysql_fetch_row($commentquery)){
    //for security, parse through the bbcode script
    //the number corresponds to the column (the message is always stored in column 4
    //COUTING STARTS at 0!!!
    	$commentbb = BBCode($commentrow[4]);
    //create the right date format
    		$commentDate = formatDate($commentrow[6]);
    
    		echo "<div class=\"commentbody\" id=\"$commentrow[0]\">\n
    		<p>$commentbb</p>\n
    		<p class=\"postedby\">Posted by ";
    		if($commentrow[3]){
    		echo "<a href=\"$commentrow[3]\">$commentrow[2]</a> ";
    		} else {
    		echo "$commentrow[2] ";
    		}
    		echo "on $commentDate | #$commentrow[0]</p>\n
    		\n</div>";
    		
    	}
    	echo "</div>";
    }
    
    function submitComments($tutid2,$tuturl){
    //a javascript script to make sure all the required fields are filled in
    ?>
    <script language="javascript">
    
    function form_Validator(form)
    {
    
      if (form.name.value == "")
      {
        alert("Please enter your name.");
        form.name.focus();
    	return (false);
         }
    
      if (form.message.value == "")
      {
        alert("Please enter your message.");
        form.message.focus();
        return (false);
      }
      
      return (true);
      }
      //-->
      </script>
    <?php
    //create the form to submit comments
    //you can add more fields, but make sure you add them to the db table and the page, submitcomment.php
    	echo "
    <a name=\"post\">
    <div id=\"submitcomment\" class=\"submitcomment\">
    <form name=\"submitcomment\" method=\"post\" action=\"submitcomment.php\" onSubmit=\" return form_Validator(this)\">
    <table width=\"20%\">
    		<tr>
    				<th colspan=\"2\"><h3 class=\"formtitle\">Leave your comment:</h3></th>
    		</tr>
    		<tr>
    
    				<th scope=\"row\"><p class=\"req\">Name:</p></th>
    				<td><input class=\"form\" tabindex=\"1\" id=\"name\" name=\"name\" /></td>
    		</tr>
    		<tr>
    				<th scope=\"row\"><p class=\"opt\">Email:</p></th>
    				<td><input class=\"form\" tabindex=\"2\" id=\"email\" name=\"email\" /></td>
    		</tr>
    		<tr>
    
    				<th scope=\"row\"><p class=\"opt\">URL:</p></th>
    				<td><input class=\"form\" tabindex=\"3\" id=\"url\" name=\"url\" /></td>
    		</tr>
    		<tr valign=\"top\">
    				<th scope=\"row\"><p class=\"req\">Comments:</p><br /></th>
    				<td><textarea class=\"formtext\" tabindex=\"4\" id=\"message\" name=\"message\" rows=\"5\" cols=\"50\"></textarea></td>
    		</tr>
    
    		<tr>	
    				<td>&nbsp;</td>
    				<td><input type=\"submit\" name=\"post\" class=\"submit\" value=\"Submit Comment\" /><br />
    				<p>Note:  Emails will not be visible or used in any way, and are not required.  Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted. </p>
    
    <p>No HTML code is allowed.  Line breaks will be converted automatically.  URLs will be auto-linked.  Please use BBCode to format your text.</p>
    
    </td>
    		</tr>
    </table>
    <input type=\"hidden\" name=\"tuturl\" value=\"$tuturl\" />
    <input type=\"hidden\" name=\"tutid2\" value=\"$tutid2\" />
    </form>
    
    
    </div>
    ";
    }
    ?>

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: PHP Comment Script

    Adjust your css

    Code:
    /*gray box*/
    .submitcomment, #submitcomment, #currentcomments, #rating, .textad {
    	background-color: #F5F5F5;
    	border: 1px dotted #ccc;
    	width: 550px;
                         margin: auto;
    	}

  3. #3
    techgeek1499 is offline x10Hosting Member techgeek1499 is an unknown quantity at this point
    Join Date
    Sep 2009
    Location
    Ohio
    Posts
    18

    Re: PHP Comment Script

    Quote Originally Posted by descalzo View Post
    Adjust your css

    Code:
    /*gray box*/
    .submitcomment, #submitcomment, #currentcomments, #rating, .textad {
    	background-color: #F5F5F5;
    	border: 1px dotted #ccc;
    	width: 550px;
                         margin: auto;
    	}
    Yay thank you. That worked perfectly Thanks again.

+ Reply to Thread

Similar Threads

  1. Cannot get php script to work
    By avidgamer in forum Free Hosting
    Replies: 3
    Last Post: 09-03-2008, 04:35 PM
  2. currently have an application pending php
    By biomasti in forum Free Hosting
    Replies: 1
    Last Post: 09-03-2008, 01:58 PM
  3. Creating MySql database/table using php script
    By bushimports in forum Free Hosting
    Replies: 1
    Last Post: 02-02-2008, 12:43 AM
  4. How to protect images without htaccess using PHP
    By frznmnky in forum Tutorials
    Replies: 0
    Last Post: 12-26-2007, 11:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers