Simple form advice for holding page

Soldato
Joined
27 Oct 2002
Posts
3,540
Location
At the fulcrum of humdrum
'lo all!

Right, I'm preparing a holding page for someone's new business venture:

http://www.plasticle.co.uk/

You'll see that there's a little form to collect email addresses of interested viewers. Obviously, when the site eventually goes live, those who've submitted their email addresses will receive an email informing them such.

Currently it's just a POST with a mailto, which is barely acceptable on lots of levels.

So what's the best way of getting this email capturing implemented?

As ever: ta in advance :)
 

Pho

Pho

Soldato
Joined
18 Oct 2002
Posts
9,324
Location
Derbyshire
A site that designs emails which needs help with email? :p.

At a very simple level, something like this (untested):

Change your form action to a subscribe page:
PHP:
<form autocomplete="off" method="post" action="subscribe.php">

On that subscribe.php have something like this:
PHP:
<?php
// No email so just bounce back to the main site
If (!isset($_REQUEST['contact-form-email'])) {
		header( 'Location: http://www.plasticle.co.uk/') ;
}

// Do some email validation here
$email_address = $_REQUEST['contact-form-email'];

if(mail("[email protected]", "Let me know when Plasticle goes live!", $email_address)) {
	$result = "Email address accepted, thank you.";
} else {
	$result = "An error occurred, please try again.";
}
?>

<html>
<p>Wrap this inside your normal template</p>
<?php echo $result ?>
</html>


A better way would be to dump their email into a database though.
 
Last edited:
Soldato
OP
Joined
27 Oct 2002
Posts
3,540
Location
At the fulcrum of humdrum
A site that designs emails which needs help with email? :p [...]
Aw, come on - it's a web page! The irony isn't lost on me, though, don't worry :D

I was hoping to do without the need for several pages. I'm sure Typekit, for instance, managed it when they pre-launched their service. Probably some whizzbang AJAXy stuff that I need to look into.

Ta for the comprehensive reply, though, Pho :)
 

Pho

Pho

Soldato
Joined
18 Oct 2002
Posts
9,324
Location
Derbyshire
Aw, come on - it's a web page! The irony isn't lost on me, though, don't worry :D

:D

I was hoping to do without the need for several pages. I'm sure Typekit, for instance, managed it when they pre-launched their service. Probably some whizzbang AJAXy stuff that I need to look into.

If you set your form's action to action="" the form will post back to the same page, you can then include that mail code at the top of the page without the need for more pages.

You can use jQuery to submit the email via AJAX (using what I've already written) without too much effort. Have a look at this plugin for jQuery which will do just that - http://malsup.com/jquery/form/
 
Soldato
OP
Joined
27 Oct 2002
Posts
3,540
Location
At the fulcrum of humdrum
Thanks for the offer, Russ, but I've just implemented a simple form from EmailMeForm, which has done the trick for now :)

EDIT: And thanks again, Pho - that link may just come in handy down the line :)

I do have an even simpler follow-up noob question:

For future work, am I right in thinking that PHP will be set up by default without me having to do a cpanel-based install or anything? It's hosted on TSOHost.
 
Last edited:
Back
Top Bottom