Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Forms Choosing Options Create a Select Menu

Malcolm Stretten
Malcolm Stretten
3,814 Points

Actually SENDING an HTML form

This tutorial doesn't tell you how to actually SEND the form.

I wonder if anyone out there can tell me what is wrong with this form. It's a template I downloaded but the bit that's not working is inside the <form action> tags.

I am using FormMail.pl and I am certain I have correctly edited it to send emails to the domain www.landlord-building-contents-insurance.co.uk

Because the form is currently called 'index.html" it's inside a folder. The form comes up perfectly when you type in landlord-building-contents-insurance.co.uk/Responsive_Form/index.html

But when you click the Submit button it keeps saying there is An Internal Server Error.

I have modified the cgi-bin permissions to 0755.

Here is the snippet of the action code in the HTML form: <form name="hongkiat" id="hongkiat-form" action="http://www.landlord-building-contents-insurance.co.uk/cgi-bin/FormMail.pl" method="post">

And here is the MODIFIED ONLY section of my FormMail.pl

Define Variables

Detailed Information Found In README File.

$mailprog defines the location of your sendmail program on your unix

system. The flags -i and -t should be passed to sendmail in order to

have it ignore single dots on a line and to read message for recipients

$mailprog = '/usr/lib/sendmail -i -t';

@referers allows forms to be located only on servers which are defined

in this field. This is a security fix to prevent others from using your

FormMail script on their web site.

@referers = (‘http://landlord-building-contents-insurance.co.uk’,’http://www.landlord-building-contents-insurance.co.uk');

@recipients defines the e-mail addresses or domain names that e-mail can

be sent to. This must be filled in correctly to prevent SPAM and allow

valid addresses to receive e-mail. Read the documentation to find out how

this variable works!!! It is EXTREMELY IMPORTANT.

@recipients = ('^info\@landlord-building-contents-insurance.co.uk’);

ACCESS CONTROL FIX: Peter D. Thompson Yezek

@valid_ENV allows the sysadmin to define what environment variables can

be reported via the env_report directive. This was implemented to fix

the problem reported at http://www.securityfocus.com/bid/1187

@valid_ENV = ('REMOTE_HOST','REMOTE_ADDR','REMOTE_USER','HTTP_USER_AGENT');

Done

2 Answers

Steven Parker
Steven Parker
231,248 Points

In addition to the folder permissions, there could be some server configuration necessary to execute your script. The script may also be executing, but encountering an internal error. These things will need to be diagnosed at the server.

To assist with the first issue, there are test scripts available that simply display the posted data back to the browser. Installing one of those would allow you to confirm that the server is actually executing the script correctly.

Malcolm Stretten
Malcolm Stretten
3,814 Points

Thanks for this answer. So, does it look like I have actually got the coding on the web form and inside the FormMail.pl correct?