Where to put PHP file?


Hello there. I am a newbie when it comes to setting up websites. I had a quick question. I used a Website Contact Form Generator for my website. I have already cut and pasted the contact htm but I have no idea where to place the PHP script?

Any help would be greatly appreciated!!


You can stick it anywhere you want … just make sure you refer to it properly in the “action” part of the form. :wink:

I’d just stick it in the same directory as the contact.htm file.



Okay, thank you. This might sound completely dumb, but how would I save the PHP file? You see, its just lines of code on a text document right now? Could I go into Dreamweaver and Save As a PHP file?


Well, you could do that, but it is certainly not needed. Just save it in any text editor (not a wordprocessor!) using a “.php” extension (or rename it if your editor forces some other filetype).



Strange, I am getting this error?

Not Found

The requested URL /contact.asp was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I changed the contact.txt to contact.php is there something else that I might have missed?


I also tried changing to asp file but am getting strange gibberish message when I try to submit.


I thought you said this was a PHP contact form script? .asp is not supported on DreamHost.

Probably, but I don’t know what, because I have not seen your script (I was just answering your questions!).

Have you looked at the DreamHost provided formmail script? This is by far the easiest way to implement this if you are not used to programming CGI applications. :wink:



Yes, it was a PHP script, my mistake I was just trying.

I am looking at the DreamHost formmail script, looks just as confusing to me! Again, I apologize for taking up your time. I was hoping that I would be able to figure things out because the generator website stated how easy it was to use.


The potential problem is that “easy” is relative, and “easy” does not necessarily mean “secure”! Many, if not most, of the PHP “formmail” scripts readily available on the web are inherently insecure, and can be exploited by spammers to send spam.

I don’t know about the one you are using (and don’t really feel like reviewing the code to see!). The DreamHost script is pretty robust (a modified version of the perlmongers NMS formmail script) and DreamHost feels it is secure enough to make it generally available.

Do you really want to get a contact form up “easily” only to have it used to send spam? Wouldn’t it be better to spend a little more effort getting it done in a secure manner? :wink:

If you provide the link to the “generator”, I’ll take a look at what you have to do to install the produced form, but I don’t want to vouch for it’s security!

Alternately, there is additional help on using the DreamHost fommail script in the DreamHost wiki. You might take a look at that, and see if it is helpful to you in implementing the DreamHost formmail script on your site.



I see your point with “easy” and “secure”!

Spam would be very irritating and bad for us. We basically needed to use the contact forms for 2 reasons: Mailing List signups and Guestlist signups for events.

I will go ahead and go with the DreamHost script and do my best! I was wondering though in your experience, does the DreamHost script allow for either an option for a Drop-Down choice or a Check Box option instead of a text box? Just curious, I will look into it more though the Wiki.


You might consider, given the DreamHost Anti-spam policy and the Terms of Service, using the DreamHost Announcement lists for “mailing list sign-ups”. The formmail script will not provide you with the audit trail you need to be compliant with those policies (the confirmed opt-in requirement and the date, time, email address, and IP address of the sign up and the confirmation). In fact. you can even use that Announcement list feature for your event sign-ups too! )and have a better audit trail!)

That said, the formmail script will also work fine though for your event signups (though using the announcement list “formmail style variation” will give you more information about the submission!). :slight_smile:

Sure! You can use any html form features you wish for collecting the data, and any data not passed as on of the “required” or “defined” variables will be sent along in the email (the wiki and the formmail page explains better how all that works).

You may want to check out an html form tutorial for a better understanding of how to create a form (or even use the “form” that was created by the “generator”, but link it to the DreamHost formmail in the “action” attribute of the “form” tag as instructed in the DH formmail documentation).




I used the form but linked the “action” to DH and it works perfectly!!!

Thank you for your help, I learned so much today!


I’m sorry, one quick question. There is a pre-made Form on the template that I am using. I used the DH and but for some reason its not working?

clear send

How did I mess this one up??


You have two starting tags:


[/quote] ... and the *first* starting tag has a "blank" action attribute. Just eliminate the first line, and you should be fine.

You also should not need (or use) the:


stuff unless you have that class defined … you can just use the DreamHost recommended:

… in it’s place. :wink:



Hmm…okay I removed the first line but when I clicked Submit, nothing happens?


Yeah … sorry about that. I stopped when I found the first issue … and there is another issue further on down the form. I edited my last post to reflect that, so you can check there for additional instructions.

Essentially, what you need to do is “merge” your “generated” form with the instructions on the DreamHost wiki … get rid of those existing submit and reset lines of code, relpacing them with the code in the DreamHost example, and it should work.

Be patient, however, before assuming it doesn’t work if you don’t get the email immediately when testing … I have found there there is often a delay in sending/receiving formmail using DreamHost (I think it is queued on the server and sent in batches).

You can also study up a bit more on the DreamHost formmail, and route the user to a special “thank you page” if you wish.



Thank you. So after the changes, the form will send to the email, but its not showing any of the fields in the email (name, email, etc). Should I just change everything to how DH is set up?


It’s not showing the field names or the field contents?



The field contents. For example I filled in my name, email, etc but in the email I received none of those were visible?


Ok … let me look at your form a little more closely, and I’ll post back.