How do I make a feedback form?

  • Thread starter Thread starter Ken
  • Start date Start date
You could do it purely in HTML with the mailto: command- would be a tad messy but functional:

Code:
<html><head><title>Feedback Form</title></head>

<body>

<form action="mailto:[email protected]" method="POST" enctype="plain">
Enter your name:&nbsp;&nbsp;<input type="text" name="Name" size="30" /><br />
Enter your email :&nbsp;&nbsp;;<input type="text" name="Email" size="30" /><br />
Enter your comments:<br />
<textarea name="Comments" rows="20" cols="30"></textarea><br /><br /><br />
<input type="submit" value="Send Feedback!" /><input type="reset" value="Clear Form" />
</form>

</body>

</html>

:)
 
You can use Rob's script: http://robm.me.uk/articles/sending-mail-with-php/

Make an html page (feedback1.html for example) which has the form on. Give each box an id and tell the form to go to feedback2.php or whatever. Then, put Rob's php send thingy on feedback2.php and tell it to get the info from the form. Stick that info into the email, and it will send the info to you.

Assuming you want it in email form anyway.
 
joeyjojo said:
You can use Rob's script: http://robm.me.uk/articles/sending-mail-with-php

Make an html page (feedback1.html for example) which has the form on. Give each box an id and tell the form to go to feedback2.php or whatever. Then, put Rob's php send thingy on feedback2.php and tell it to get the info from the form. Stick that info into the email, and it will send the info to you.

Assuming you want it in email form anyway.

Ken said:
I don't think my Eclipse webspace supports php.

;)
 
Thanks a lot guys :)
Trigger said:
You could do it purely in HTML with the mailto: command- would be a tad messy but functional:

snip

:)
I copied and pasted this into notepad and uploaded the htm file to my webspace and tested it out. When I hit "Send Feedback" it opened up my Mozilla Thunderbird... :confused:

I'm under the impression that whoever sends feedback will do it solely using the form without his/her email client launching?

Thanks again.
 
Just found this...

http://www.englib.cornell.edu/instruction/www/email-forms-class.html

...and it looks like I need a CGI script which my webspace also doesn't support! :(
Eclipse said:
Will not support your own server side scripts, should you need to run your own scripts on the server, such as PHP, CGI, ASP, etc, you will need to go for a Domain Hosting package.
Think I might go signup for some webspace with Register1. :)
 
Ken said:
Thanks a lot guys :)

I copied and pasted this into notepad and uploaded the htm file to my webspace and tested it out. When I hit "Send Feedback" it opened up my Mozilla Thunderbird... :confused:

I'm under the impression that whoever sends feedback will do it solely using the form without his/her email client launching?

Thanks again.

Well yes, using the mailto command uses the clients email program to actually send the mail but takes all the input from the form :)
 
Ken said:
Thanks a lot guys :)

I copied and pasted this into notepad and uploaded the htm file to my webspace and tested it out. When I hit "Send Feedback" it opened up my Mozilla Thunderbird... :confused:

I'm under the impression that whoever sends feedback will do it solely using the form without his/her email client launching?

Thanks again.

Nope, you can't do that without something server side. Get any kind of paid web hosting, then you'll have PHP :)
 
OK, I've copied and pasted the following into notepad naming it mail.php - Thanks Rob. :)
Code:
<?php

// CONFIG
$mail_to = 'myemailaddress';
// END CONFIG

session_start();

function strip_mail_headers_single( $string ) {
    return preg_replace('/(%0A|%0D|\\n+|\\r+)/i', '', $string);
}

function strip_mail_headers_multi( $string ) {
    return preg_replace('/(%0A|%0D|\\n+|\\r+)(content-type:|to:|cc:|bcc:)/i', '', $string);
}

function is_valid_email( $string ) {
    return preg_match('^[\_]*([a-z0-9]+(\.|\_*)?)+@([a-z][a-z0-9\-]+(\.|\-*\.))+[a-z]{2,6}$', $string);
}

function send_mail($to, $from, $from_mail, $subject, $message) {
    if ( empty($from) || empty($from_mail) || empty($subject) || empty($message) ) {
        return -1;
    }

    if ( $_SESSION['last_mailed'] + 180 < time() )
        return -2;

    if ( !is_valid_email($from_mail) )
        return -3;

    $from = strip_mail_headers_single($from);
    $from_mail = strip_mail_headers_single($from_mail);
    $subject = strip_mail_headers_single($subject);
    $message = strip_mail_headers_multi($message);

    $_SESSION['last_mailed'] = time();

    return mail($to, $subject, $message, "From: $from <$from_mail>\r\n");
}

if ( !empty($_POST) ) {
    $result = send_mail($mail_to, $_POST['from'], $_POST['from_mail'], $_POST['subject'], $_POST['message']);

    if ( $result == -1 ) {
        echo "<p>Whoops! You need to complete all the fields.</p>";
    } elseif ( $result == -2 ) {
        echo "<p>Whoah, slow down there cowboy! You can only send one mail every three minutes.</p>";
    } elseif ( $result == -3 ) {
        echo "<p>Please enter a valid email address.</p>";
    } else {
        echo "<p>Mail sent successfully!</p>";
    }
}

?>
I've copied and pasted the following on one of my webpages that is in the same directory as mail.php
Code:
<form method="post" action="mail.php">

    <p><label for="from">Your name:</label></p>
    <p><input type="text" name="from" id="from" /></p>

    <p><label for="from_mail">Your email address:</label></p>
    <p><input type="text" name="from_mail" id="from_mail" /></p>

    <p><label for="subject">Subject:</label></p>
    <p><input type="text" name="subject" id="subject" /></p>

    <p><label for="message">Message:</label></p>
    <p><textarea name="message" id="message"></textarea></p>

    <p><input type="submit" value="Send Message" /></p>

</form>

But when I test it, I don't get an email in my inbox.

Any ideas?

Cheers.
 
Hmmm, now I'm getting...

"Whoah, slow down there cowboy! You can only send one mail every three minutes."
 
Ken said:
Hmmm, now I'm getting...

"Whoah, slow down there cowboy! You can only send one mail every three minutes."
Should be fine from the look of the code. You know this is a php solution right? As you're getting a message it seems php is working.

Wait 3 minutes? :D
 
I understand what each line of the above code is doing but as for each individual character of the code, well I thought I'd post it so thanks for checking it through Joe. :)

I've given it more than 3 minutes a few times and it still doesn't work. I'll try again when I get back home.
Yep, I've recently bought a domain and webspace from Register1 as I wanted php support. I did try another piece of feedback form code I found online (it worked) but I wasn't sure if it would be secure from spam and whatever else and robmiller seems a regular in this section and proficient at this sort of thing.
 
I gave this a test today, using exactly what you posted Ken, and it does indeed stop working after the first go. Couldn't see where it was going wrong, though my PHP knowledge isn't brilliant.
 
Back
Top Bottom