Feedback Forms

They have: 5 posts

Joined: Sep 2000

Hi.

Can anyone please tell me all about feedback forms, what types there are, how to do them, what is and is not possible, how to vary them etc etc.

I want a feedback form for my site, any help is very welcome

cheers all

Ben

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

Well thanks for narrowing that down Smiling.

Well lets see....there are forms that can be sent to your email, written to a page, appended to a database, and also thrown out into to the null. It's possible to make it with perl/cgi. It's also possible to email the results with just html(enctype="text/plain"). However it is not possible to pass a roadside sobriety test if you keep dancing the straight line. You can vary these forms, by adding different stuff..like DOGTAG: opposed to NAME: and stuff like that.

Now I will tell you what I think I would do...

I would think about my situation,..
Do I want this feedback form to be seen on my website?
Do I want it to be seen as soon as the user submits it or do I want to monitor the posts?
Do I want to be able to search it?
Am I worried about people messing with it?
Do I have security issues to worry about?
So on and so forth.

Then after answering a bunch of questions you have a better idea of where you must start, and where you must eventually end up.

Hope that helps some

Pimpin like a pimp with an electrofied pimpin machine!

They have: 5 posts

Joined: Sep 2000

Well all i really wanted was a feedback form code that was basic and the instructions on how to use it. I can then mess about with it, all i want it to do is submit the results to a mail account.

now wheres that code Wink

I am still trawling the net looking for a good tutorial

They have: 850 posts

Joined: Jul 1999

I wrote a really basic Feedback script which allows a user to input his name,email and feedback. The script will than make sure the variables are not left empty, and send the email using sendmail. If any of the fields are empty, an error message will show up. The code has been tested, so it does work.

#!/usr/bin/perl


#COPY/PASTE THE FOLLOWING HTML
#<form action="/cgi-bin/feedback.cgi" method="POST">
#<b>NAME</b>: <input name="name" type="text" maxlength="30"><br>
#<b>EMAIL</b>:<input name="email" type="text" maxlength="60"><br>
#<b>COMMENTS</b>:<br>
#<textarea name="feedback" rows=10 cols=30 ></textarea><br>
#<input type="submit" value="Send Feedback">
#</form>
$mail_prog = '/usr/lib/sendmail'; #Path to sendmail
$your_email = '[email protected]';#Email you want the feedback sent to
$url = 'http://www.google.com'; #URL user is forwarded to after he completes form

#Parsing the input
&parseinput;

#Emailing Feedback if all of the variables are filled out
if($field{'name'} && $field{'email'} && $field{'feedback'})
{

open (MAIL, "|$mail_prog -t");
print MAIL "To: $your_email\n";
print MAIL "Reply-to: $field{'email'}\n";
print MAIL "From: $field{'name'}\n";
print MAIL "Subject: Feedback\n";
print MAIL "\n\n";
print MAIL "IP: $ENV{'REMOTE_ADDR'}\n";
print MAIL "Browser: $ENV{'HTTP_USER_AGENT'}\n";
print MAIL "Name: $field{'name'}\n" ;
print MAIL "Email: $field{'email'}\n" ;
print MAIL "Feedback: $field{'feedback'}\n" ;
print MAIL "\n\n";
close (MAIL);
print "Location: $url\nURI: $url\n\n" ;

}
else
{
#Informing user to fill out all fields
print "Content-type:text/html\n\n";
print '<html><title>Error with Feedback</title><body><b>Please enter information in all of the fields. Press back</b></body></html>';
}

sub parseinput {

(*fval) = @_ if @_ ;

local ($buf);
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN,$buf,$ENV{'CONTENT_LENGTH'});
}
else {
$buf=$ENV{'QUERY_STRING'};
}
if ($buf eq "") {
return 0 ;
}
else {
@fval=split(/&/,$buf);
foreach $i (0 .. $#fval){
($name,$val)=split (/=/,$fval[$i],2);
$val=~tr/+/ /;
$val=~ s/%(..)/pack("c",hex($1))/ge;
$name=~tr/+/ /;
$name=~ s/%(..)/pack("c",hex($1))/ge;

if (!defined($field{$name})) {
$field{$name}=$val;
}
else {
$field{$name} .= ",$val";


}


   }
}
return 1;
}
'

If you have any questions, feel free to ask.

Hope that helps.

They have: 5 posts

Joined: Sep 2000

Thanks a lot for that,

do i just cut and paste the code into the body of a web page and go from there.

What do i need to change for it to work for me ?

thanks for being patient, I am learning, I am just slow !

They have: 850 posts

Joined: Jul 1999

Add

NAME:
EMAIL:
COMMENTS:

to any html page.

Than copy the whole code above, open notepad and paste. Edit the variables (ie '$url' and $your_email', and verify with your host that the path to sendmail is correct). Now, name the file 'feedback.cgi'. Upload it to your cgi-bin and chmod it to 755 or 777.

Hopefully it will work then.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

PHP is better! If your server supports it, look into a PHP emailer.

This is an example. It should work, but you may want to get more etravagant.

(mail.php)

if($field{'name'} && $field{'email'} && $field{'feedback'}) {
# Put your email address here
$MailTo = "[email protected]";

# Put the subject you want here
$MailSubject = "My Subject Line";

# This is the message
$MailMessage = $Message;

# Add extra headers
$MailExtra = "From: ".$Name." <".$Email.">\n";
$MailExtra .= "Reply-To: ".$Email."\n";
$MailExtra .= "Content-Type: text/plain\n";

# Send the mail!
mail($MailTo, $MailSubject, $MailMessage, $MailExtra);
}
else {

#Informing user to fill out all fields
echo "Content-type:text/html\n\n";
echo "<html><title>Error with Feedback</title><body><b>Please enter information in all of the fields. Press back</b></body></html>";

}
'

You can assign $MailTo, $MailSubject, $MailMessage to a variable that is passed via POST/GET, or set it to a string (i.e. "My string")

(any html page)

<form action=mail.php method=POST>
<b>NAME</b>: <input name="Name" type="text" maxlength="30"><br>
<b>EMAIL</b>:<input name="Email" type="text" maxlength="60"><br>
<b>COMMENTS</b>:<br>
<textarea name="Message" rows=10 cols=30 ></textarea><br>
<input type="submit" value="Send Feedback">
</form>
'

It can be that simple! or.. you can have a whole lotta more fun. You see, with PHP, there is no need to do all that work to get stuff from POST/GET... it does that for you.

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 5 posts

Joined: Sep 2000

Yeah i think that my server does run PHP how can i check is there a website where you can check what server you are running ?

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

create a file, name it whatever... but make the extension '.php' or '.php3'

put this in it..

<?
phpinfo();
?>
'

Now point your browser to it. If your running PHP, this will show you ALL the information you could ever want about how your server has PHP configured.

Easy, huh?

also, I forgot to send the visitor somewhere after the mail is sent...
just add this after the mail() line:

Header("Location: your.com/here.html");
'

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 5 posts

Joined: Sep 2000

Wow,

that is really neat, I really like that.

Is there any way that you can configure that so you can see what other peoples servers are running

<?
phpinfo();
add host name here or something
?>
'

if you could tell me any other little tricks of the trade would love to know !
Smiling

thanks a lot

~Ben

They have: 5 posts

Joined: Sep 2000

max,
is should write (mail.php) code, save it as "mail.php", upload it in the same dir where the html with
tag is and it should work?
is that right
i just did it on a free host server and it doesn't work?
where am i wrong?
or it's because of the host (it's bizland.com)
thanks

ggogggo

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

ggogggo-
Yes, that is how it should work.

Earlier today, I looked at bizland.com and couldn't find any documentation on what stuff they support.

My advice is to contact someone and ask what they support (CGI, PHP, SSI, etc.). Or you could try the phpinfo() thing. That is like a fail proof thing. (As far as I know) no matter the version of PHP that is running, that will show all the available info. (Only if PHP is supported).

Anyone interested in PHP? I do recommend php.net as a desk-reference. I've had no problem finding info on functions. And usually, it's good enough to slap some sense into me.

Mark Hensler
If there is no answer on Google, then there is no question.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.