Using url redirect in php to subscribe if check box checked

I'm trying to use url redirecting to capture subscribes as described here: http://www.campaignmonitor.com/blog/archives/2006/03/tip_capturing_subscribers_from.html

but I keep getting the following campaign monitor error:
"We apologize for the inconvenience but an error has occurred. Please try again later."

My form code for the email field looks like:
<input name="email" type="text" id="email" value="<?php echo $_GET['email'];?>"/>

And for the check box:
<input id="subscribeme" name="subscribeme" type="checkbox" value="True" /><label for="subscribeme">Subscribe me.</label><br /><?php echo $_GET['subscribeme'];?>

Finally my php script does:
$email = $_REQUEST['email'] ;

if (isset($_REQUEST['subscribeme'])) {
//if checked box, then redirect to subscribe url with the email address.
header("Location: http://xxxxx.cmail1.com/s/xxxxx?email=$email");
exit;
}
else { // ....redirect to thankyou page}

The redirect commences but then there is that strange error saying to try again later.
Can anyone see what I'm doing wrong as I don't know my way around forms or php very well.

nellyspinn, 8 years ago

Oh dear, I was missing a slash. I guess I'll leave this up as it took me a while to figure out the php. Perhaps it i will be of use to someone.
Fixed line:

header("Location: http://xxxxx.cmail1.com/s/xxxxx/?email=$email");

This however gives me a captcha page which I thought was only for older forms using the old domain and not cmail1.

Any work around on that would be appreciated since I already include captcha verification on my own form.

Mathew Mathew, 8 years ago

Hi,

Glad you sorted that out. The CAPTCHA only shows if you don't have the right email field form name - using a name="email" is too easy for spam bots to fill in. If you use instead the name of the field in your account it should work.


Get in touch with us on Twitter: http://twitter.com/campaignmonitor
We're also on Facebook: http://facebook.com/campaignmonitor
nellyspinn, 8 years ago

Thanks!

nellyspinn, 8 years ago

Hi again, new question, I got it working without the captcha showing up. I have now tried to add some custom fields and send them via redirect in my php header like so:

(Location:http://xxxxx.cmail1.com/s/xxxxx/?cm-xxx-xxx=
$email&name=$name&State=$State&City=$City")

Only name and email get registered however. The custom fields are named in campaign monitor and in my forms input statement exactly as above "State", "City", etc..

Thanks.

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098