Need to collect email addresses.
LO,
OK, I am wanting to put a simple form on my website to collect:
Firstname
Lastname
Email Address.
I am reasonably happy about creating the form in HTML using Dreamweaver or hand-coding it from other examples.
However, I have no idea how to install this on my website.
I do not wish to use an email manager program if I can avoid it.
Where should I start?
Thanks,
T
Busy posted this at 10:27 — 3rd February 2005.
He has: 6,151 posts
Joined: May 2001
Are you able to use server side, such as PHP or ASP ?
You can email the content direct to your email (by using the action field), but with server side you can do validation (can with javascript but if its disabled your up the creek), send usewhere are and other things.
Telemicus posted this at 14:02 — 3rd February 2005.
He has: 33 posts
Joined: Dec 2004
I had another look at my hosting package and yes it does mention PHP support and Perl Support. I don't see anything about ASP support. Would PHP be easier - I'm afraid I don't currently know anything about it either.
It has Formmail as a Free Plugin and also mentions PHP Nuke? All new territory for me but I am always willing to learn.
Let me know if you think you know the route I should go.
Thanks,
Dog Training Videos | PS Vita Game Downloads | Hunting Tips | Skeet Shooting
andy206uk posted this at 15:14 — 3rd February 2005.
He has: 1,758 posts
Joined: Jul 2002
Where do you want the details to end up? Do you want them to be emailed to you? put in a database? put in a text file? or something else?
Telemicus posted this at 19:18 — 3rd February 2005.
He has: 33 posts
Joined: Dec 2004
Actually Andy, any of the above would be fine. I would prefer them to be sent to some sort of database but this could be nothing more than just a CSV file.
Dog Training Videos | PS Vita Game Downloads | Hunting Tips | Skeet Shooting
andy206uk posted this at 21:50 — 3rd February 2005.
He has: 1,758 posts
Joined: Jul 2002
Right... ok firstly you need a form, I'm guessing you know how to build them. Let's say the fields are called "firstname" "lastname" and "email" and we're going to store them in a text file one on each line with the data seperated by tabs (for easy importing into excel and then into a mail merge).
At it's most basic level when the user submits the code you need to do something like this:
Firstly, you need the form to POST the data to the php script, for example call it "emailcollector.php". Second, you need to create a file on the server in the same directory as emailcollector.php and call it "data.txt". The permissions (chmod) need to be set to 777.
(just so you know, \t is a tab character and \n is a newline).
This goes in your "emailcollector.php" file.
<?php
//create data line to go into database
$data = "$_POST[firstname]\t$_POST[lastname]\t$_POST[email]\n";
//Open data file for writing
$filename = "data.txt";
$filepointer = fopen($filename, a);
//Write data to file
fwrite($filepointer, "$data");
//Close file
fclose($filepointer);
//redirect to thankyou page
header("Location:http://www.yourwebsite.com/thankyou.html");
?>
And thats all there is to it. Simple huh?
Andy
CptAwesome posted this at 22:30 — 3rd February 2005.
He has: 370 posts
Joined: Dec 2004
Yeah, and you can throw in some validation too like
if($_POST['firstname'] && $_POST[lastname] && $_POST[email])
{
// the rest of the code;
}
totally simple validation, but makes sure the fields aren't empty.
andy206uk posted this at 15:29 — 4th February 2005.
He has: 1,758 posts
Joined: Jul 2002
All together with validation it would look something like this:
<?php
if($_POST['firstname'] && $_POST[lastname] && $_POST[email]) {
//create data line to go into database
$data = "$_POST[firstname]\t$_POST[lastname]\t$_POST[email]\n";
//Open data file for writing
$filename = "data.txt";
$filepointer = fopen($filename, a);
//Write data to file
fwrite($filepointer, "$data");
//Close file
fclose($filepointer);
//redirect to thankyou page
header("Location:http://www.yourwebsite.com/thankyou.html");
} else {
//redirect to error page
header("Location:http://www.yourwebsite.com/error.html");
}
?>
Andy
Telemicus posted this at 15:56 — 4th February 2005.
He has: 33 posts
Joined: Dec 2004
That's great guys. Let me try that out over the weekend and I'll get back to you to let you know my success or otherwise.
Thanks a bunch.
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.