Kind of... template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xjohnieboyx
    FFR Player
    • Feb 2006
    • 1630

    #1

    Kind of... template

    So I'm just asking here since I don't know where to look for one of these:

    I want to have comments after a certain article that users can write and have it right under the article when they submit. This involves some CSS/Javascript I assume but I'm almost positive there has to be a template somewhere.

    To be clearer, imagine an article, followed with a link to a window where they type their name, e-mail, and the actual comment, after which they'll hit submit and be redirected back to the article. Then, they'll be able to see their comment sitting right under the article, as will every other reader.


    Please reply if I'm being unclear or if you could aid me... something of that nature
  • g4z33b0
    Banned
    • Mar 2006
    • 2618

    #2
    Re: Kind of... template

    Just get a free Wordpress account, they should have one somewhere on their site. Wordpress is really reliable and efficient, probably your best bet.

    Comment

    • xjohnieboyx
      FFR Player
      • Feb 2006
      • 1630

      #3
      Re: Kind of... template

      Here's a page for reference


      If you scroll to the bottom you'll find the Reviews. That's what I want to make.

      The question is: How?

      Comment

      • g4z33b0
        Banned
        • Mar 2006
        • 2618

        #4
        Re: Kind of... template

        a form that feeds to a mysql database, using php i think i have like a template of something like that, i'll edit it in

        Comment

        • Summerschool
          ~
          • Feb 2012
          • 320

          #5
          Re: Kind of... template

          Here is a really simple "template" that I just wrote. I didn't test it, so I don't know if would even work. Commented most of the php...
          This would require a MySQL database with a table containing the fields title, name, email, content, time.

          Code:
          <?php
          //connect to MySQL server
          //localhost = server address
          //user = MySQL username
          //pass = MySQL password
          $connection = mysql_connect("localhost", "user", "pass");
          //select DB to use
          mysql_select_db("comments_db");
          //has someone submitted a comment?
          if(isset($_POST['submit_button'])) {
          	//get post values from form
          	$name = $_POST['name_value'];
          	$email = $_POST['email_value'];
          	$title = $_POST['title_value'];
          	$content = $_POST['content_value'];
          	//add the comment to the database
          	$query = "INSERT INTO comments_table (title, name, email, content, time) VALUES('".$title."','".$name."','".$email."','".$content."', '".time()."')";
          	//did comment get added successfully?
          	if(mysql_query($query)) {
          		$submit_text = "Comment Added<br />";
          	//if not lets tell them it failed
          	} else {
          		$submit_text = "Comment Failed<br />";
          	}
          }
          //select all the comments from the database
          $query = "SLEECT * FROM comments_table ORDER BY time";
          $result = mysql_query($query);
          //loop through all the comments and display them
          while($comment = mysql_fetch_array($result, MYSQL_ASSOC)) {
          ?>
          <?php print($submit_text); ?>
          <div style="border:1px solid #000;background:#CCC;width:200px;margin:2px;padding:2px;color:#FFF;">
          <?php print($comment['title']); ?> - <?php if(!empty($comment['email'])) { ?><a href="mailto:<?php print($comment['email']); ?>"><?php print($comment['name']); ?></a><?php } else { print($comment['name']); } ?><br /><br />
          <?php print($comment['content']); ?>
          </div>
          <?php } ?>
          <form method="post">
          Name: <input name="name_value" type="text"><br />
          Email: <input name="email_value" type="text"><br />
          Title: <input name="title_value" type="text"><br />
          <textarea name="content_value" cols="30" rows="4"></textarea><br />
          <input name="submit_button" type="submit" value="Submit">
          </form>
          Edit: BTW, this has no security, and shouldn't be used in a real site without modification.
          Last edited by Summerschool; 07-15-2007, 11:52 AM.

          Comment

          • xjohnieboyx
            FFR Player
            • Feb 2006
            • 1630

            #6
            Re: Kind of... template

            Thanks a lot, Summerschool. I'm definitely going to study that. Maybe I'll PM you later.

            Again, thanks.

            Comment

            • g4z33b0
              Banned
              • Mar 2006
              • 2618

              #7
              Re: Kind of... template

              Here's the simple form code:

              Code:
              <form id="contact" name="contact" method="post" action="">
                <table width="600" border="0" align="center" cellpadding="5" cellspacing="0">
                  <tr>
                    <td width="110" valign="top" >Full Name:</td>
                    <td width="470"><input name="name" type="text" id="fullname" size="30" value=""/></td>
              
                  </tr>
                  <tr>
                    <td valign="top" >Email Address:</td>
                    <td><input name="email" type="text" size="30" value=""/></td>
                  </tr>
                  <tr>
                    <td valign="top" >Subject:</td>
                    <td><input name="subject" type="text" size="30" value=""/></td>
              
                  </tr>
                  <tr>
                    <td valign="top" >Message:</td>
                    <td><textarea name="message" cols="60" rows="10" id="message"></textarea></td>
                  </tr>
                </table>
                <p align="center">
                  <input name="contact" type="hidden" value="contact" />
              
                  <input type="submit" name="Submit" value="Submit" />
                </p>
              </form>
              But you probably already have that hah

              Comment

              Working...