Help with Scripts, forms, etc


I’m not sure if this is the forum for this post, but there are no posts in e-commerce so I’ll try it here and see what happens. I’m hoping to add a form to my webpage that collects names and email addresses, then directs the person to a download page. I’m pretty sure I can create the necessary form, but I don’t know anything about putting it up, or getting it to work as I hope to. If anyone can point me to any good resources where I might learn that stuff, without being too technical, I’d greatly appreciate.



The normal way of doing this would be this:

(a) User fills in form and hits Submit
(b) Form data is collected by a PHP script and sent to a MySQL database file.
© Script redirects to download page.

Presumably, the download page will only work if a user has filled in the form, so you could setup MySQL to return a unique ID (following the data insert) that the download page can recognize.

You therefore need a basic understanding of PHP and MySQL to do a thorough job of this.

Alternatively, you can have the script email you the form data. The PHP script that handles the form data must be capable of figuring out whether or not it is okay to redirect to the download page.

Simon Jessey
Keystone Websites | si-blog

Thanks Simon.

I’ve read what you posted and poked around some more on my Dreamhost control panel. I wonder if you (or anyone else) would mind reading this and telling me if I’m on the right track, recommend avenues for further study, etc.

I see that I can set up a mysql database pretty easily. Once I do that, is it easy to edit? I’ll only really be collecting names & email addresses, so it won’t be too extensive - can I edit it to compile just two fields worth of data? Once I have a functional database, can I download the information periodically and clear the database to start over? I’ve found some PHP / My SQL Tutorials on the web which I’ll read over the next week or so.

I also know that Dreamhost provides formmail for free, along with detailed instructions. I see a redirect command there, which I assume will direct the visitor to a page I choose. I also see a field called “required” which will allow me to ensure that anyone who doesn’t fill in the fields cannot go on to the next page. I don’t know, though, if there’s a way for me to insure that they give a valid email address. I suppose I could redirect them to an autoresponder and email them a link to the download page? Or maybe I need to know some more coding to make that happen?

Well, as always, thank you for any help.


DreamHost makes phpMyAdmin available to you, which makes it very easy to add, edit, and delete tables, fields, and records. It also allows you to export your data in various different ways.

I’m afraid I’m not familiar with formmail, since I always write my own things to do this; however, if you have a basic knowledge of PHP, it is actually quite easy to do. Validating email addresses is not a difficult task to do, but it is easy for someone to give you a perfectly valid, but totally bogus address. Emailing them a link to the download page certainly gets around that problem. PHP can easily handle the email aspect as well.

Simon Jessey
Keystone Websites | si-blog

All right, thanks so much. I’ll start learning PHP!

Thank you,


There is quite a lot of basic information about PHP on the DreamHost Wiki:

I also created a companion article that demonstrates how to use PHP to connect to and query a MySQL database:

Simon Jessey
Keystone Websites | si-blog


I set up a database, and that PHP My Admin place is totally confusing - is there a “for beginner’s” tutorial anyplace? I’ve got a database, and I’ve created two fields, “Name” and “Email” but I don’t have a clue where to go from there. What I want to do is figure out how to get the data that people enter into my form into the database, so I can collect the leads for follow up emails. I may be getting in over my head here?



I’ve not actually tried the code below. It’s done from experience :P. But it should get you on the right track.
Takes a name and email address. If they are empty or the email is not valid, it won’t send an email. Once it’s valid, it will send an email to the person with a link to the download page, and it will also send you an email with their details.
You should look at the code in the second file and try to understand what happens.
It’s not the best or most robust but it should help you get to understand some PHP. It’s always good to know PHP if you are making web sites =). Good luck!



Chris - another option is to “outsource” this work to an autoresponder service. e.g. and there are others.

Just a suggestion if you are spending too much time learning sql , php, etc. for this fairly common task.


Use sweetdream25 at signup for an instant $25 off your new account. Not sure which DreamHost plan is best? This chart lists the plans.

I think the formmail solution should work too, if soft security is ok.