View Full Version : Easiest way to create a PHP for opt-out
mdiehl
02-27-2008, 09:33 PM
Hello everyone! I'm a relative noob to PHP, and I'm trying to find the most simple way for someone to unsubscribe to the newsletter without having to resort to a mailto command.
The optimum soltuion would be for the link to trigger a PHP command that will capture the sender's email address, and automatically send to a specified email box with the subject "unsubscribe".
I tried writing a PHP script that would send to a basic database file, but it requires me to add several other steps to gather these Email address. By including "unsubscribe" in the subject line has automated actions already in place that I can use without further probems.
I know this is quite simple to what other people are using PHP for, but I need to take baby steps here or I'll get extremely lost.
Thanks in advance for any assistance!
Matt
Leafy
02-27-2008, 10:32 PM
<?php
$sub_email = $_GET["email"];
mail("unsubscribe@yournewsletter.com","unsubscribe",$sub_email);
?>
Is this what you're talking about?
mdiehl
02-28-2008, 12:49 AM
I think so.
I'm going to throw this in and give it a try....I knew there would be a relatively easy answer....I apparently was just overthinking the solution!
Matt
mdiehl
02-28-2008, 01:38 AM
Leafy,
I was able to create the PHP form, FTP it to my server, and set the link on the newsletter to refer to my newly created PHP document. However, upon cliking on the link, it does grab my browser, but it's not submitting any form.
I'm assuming that the error is in the link itself.
Currently I wrote the link to only refer to the PHP (for example)
http://www.theunderachieversband.com/optout.php?$sub_email = $_GET["email"]
Can you verify if this is where the error resides?
Thanks!
Matt
thetestingsite
02-28-2008, 01:47 AM
This is how you want it:
/optout.php?email=$_GET["email"]
or
/optout.php?email=test@test.com
Hope this helps.
mdiehl
02-28-2008, 04:26 AM
Thanks for the great feedback!
I'm now getting responses in the email account, but there's still a little glitch happening in the Email address. The first part of the string is correct, but everything after the "@" is garbled with p3slh145.shr.phx3.secureserver.net
I attempted to reply from several different email account types (hotmail, gmail, outlook, exchange) and the response email is identical from every address.
I really hate to continue to add more to the thread, but frankly this is the only way I'm gonna learn this. ;)
Have a great one tonight all!
Matt
thetestingsite
02-28-2008, 04:34 AM
k...try this as your form on the page that you want it go on:
<form action="unsubscribe.php" method="POST">
Email: <input type="text" name="email"> <input type="submit" value="Unsubscribe">
</form>
Then, as unsubscribe.php:
<?php
mail("unsubscribe@yournewsletter.com","unsubscribe", $_POST['email']);
?>
The above will produce an email in the form of the following:
to: unsubscribe@yournewsletter.com
subject: unsubscribe
body: {whatever was typed in the form}
Hope this helps.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.