Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2012
    Posts
    16
    Thanks
    8
    Thanked 0 Times in 0 Posts

    How to create a Feedback Form?

    How can I add a feedback form to my site? I don’t want an email to be sent to my email, I want the comment to appear immediately on the page when the submit button is clicked. Only name, surname, date and comment are needed for the form. How do I do this?
    Sorry if this was already asked, but I did search the site for this subject but couldn’t find anything.

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello ElysiaD,
    That's more like a comment script. Check this one out - http://www.gentlesource.com/comment-script/ or google for more.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • Users who have thanked Excavator for this post:

    ElysiaD (04-11-2013)

  • #3
    New Coder
    Join Date
    Feb 2012
    Posts
    16
    Thanks
    8
    Thanked 0 Times in 0 Posts
    @Excavator - Thanks for the links. Can I use these scripts in Dreamweaver? If so, how do I install and use it in Dreamweaver? I want the form to be on the testimonials page only. I don't have any experience in php so any help will be great. Thanks
    Last edited by ElysiaD; 04-09-2013 at 08:22 AM.

  • #4
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    you can use this, but you'll have to tweak it. there's no pagination there, and comments are stored in text files. but it will give you an idea how to do it
    Code:
    <?php
    if(isset($_POST['comment'])){
    	//name, email, comment
    	$nr = 0;
    	$file = 'comments/' . time() . '-' . $nr;
    	while(file_exists($file)){
    		$nr++;
    		$file = 'comments/' . time() . '-' . $nr;
    	}
    	$message = htmlspecialchars($_POST['name']) . '<-->' . htmlspecialchars($_POST['email']) . '<-->' . nl2br(htmlspecialchars($_POST['comment']));
    	file_put_contents($file, $message);
    	//uncomment if you want email every time you get new comment
    	//$to = 'user@email.com';
    	//$subject = 'New comment';
    	//$body = htmlspecialchars($_POST['email']) . "\n\n" . htmlspecialchars($_POST['comment']);
    	//mail($to, $subject, $body);
    }
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>comments</title>
    
    
    </head>
    
    <body>
    <div class="contents">
    
    <?php
    $temp = '<div style="border:2px #090 solid; margin-left:100px; margin-right:100px; margin-bottom:5px">
    	<div style="background-color:#6F9; position:relative; padding:4px">
        	<div style="font-weight:bolder; display:inline; min-width:150px;">
            [[name]]
            </div>
        	<div style="display:inline; color:#666">
            [[date]]
            </div>
        </div>
        <div style="clear:both; border-bottom:thin solid #6F9; border-left:thin solid #6F9; border-right:thin solid #6F9; min-height: 60px; padding:10px">
        [[comment]]
        </div>
    </div>';
    
    $files = glob('comments/*');
    if(isset($files[0])){
    	sort($files);
    	date_default_timezone_set('UTC');
    	$i = 0;
    	while(isset($files[$i])){
    		$data = file_get_contents($files[$i]);
    		$data = explode('<-->', $data, 3);
    		$tmp = explode('-', basename($files[$i]));
    		$post = str_replace('[[date]]', date('l, F jS Y', $tmp[0]), $temp);
    		$post = str_replace('[[name]]', $data[0], $post);
    		$post = str_replace('[[comment]]', $data[2], $post);
    		$i++;
    		echo "\n" . $post;
    	}
    }else{
    	echo '<div style="text-align:center; font-size:20px">There are no comments yet.<br />Leave one ;)</div>';
    }
    ?>
    
    <div style="border:2px #090 solid; width:700px; margin-left:auto; margin-right:auto; margin-bottom:5px">
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <div style="text-align:right; margin-left:50px; margin-right:50px">
    	name:
    	  <input name="name" type="text" style="width:300px; border: 3px solid #CCC" class="photoCaptchaRequired" />
    </div>
    <div style="text-align:right; margin-left:50px; margin-right:50px">
    	email (won't be displayed): <input name="email" type="text" style="width:300px; border: 3px solid #CCC" class="photoCaptchaRequired" />
    </div>
    <div style="text-align:right; margin-left:50px; margin-right:50px">
      <textarea name="comment" cols="" rows="" style="width:590px; height:100px; border: 3px solid #CCC" class="photoCaptchaRequired"></textarea>
    </div>
    
    <div style="text-align:center"><input name="submit" type="submit" value="send" style="border: 3px solid #CCC" /></div>
    </div>
    
    </form>
    </div>
    
    </div>
    
    </body>
    </html>

    -------------------------------------------------------------------------------
    "Real Programmers can write assembly code in any language" - Larry Wall

  • Users who have thanked patryk for this post:

    ElysiaD (04-11-2013)

  • #5
    New Coder
    Join Date
    Feb 2012
    Posts
    16
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Thanks everyone for your help so far. In my search for a comment box, I've stumbled upon http://www.htmlcommentbox.com. It is a site that generates the code for you. No hassles and very easy. Just copy the code into your site. You can style it the way you want with css. You can also be the moderator so you have complete control of the comments and it has anti-spam and anti-bot software. There is a lot more features so I'll be using this for now until I get more clued up with php


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •