Populate form text box from URL for email unsubscribe link

We are doing a simple email campaign and need to include an unsubscribe link. I have the page and db built for the page however I’d like the ‘email’ field to populate from a unique url, such as:

www.myweb.com/[email protected]

I can’t seem to get this info from the url to the text box. Thanks in advance for any assistance!

When text is passed into a page from an argument such as your “[email protected]”,
it is posted to the page. BUT, it is NOT a POST variable. POST is used for FORM’s posting to pages.
You need to use GET’s instead.

So, on your unsubscribe.php page, you would add code to “get” the info. Use something like this:
[php]
$unsubscribe_email = $_GET[‘email’]; //Get the email sent from the user-click…
[/php]

Hope that helps… (If not, show us some code!)

Here’s the working end of the code:

[code]

<!-- START: main -->
<div id="main">

	<?php include('inc/masthead.inc.php'); ?>

	<!-- START: flash-content -->
	<div id="flash-content">
		
	</div>
	<!-- END: flash-content -->

	<!-- START: content-wrapper -->
	<div id="content-wrapper">

		

		<!-- START: primary-content -->
		<table id="primary-content" cellspacing="0">
		<tr>
		
		</tr>

		<tr>
		<td id="body">
			<table id="columns" cellspacing="0">
			<tr>
			<td>
				<h2>Unsubscribe From Our Mailing List</h2>
Email:
			</tr>
			<tr><td id="gutter">&nbsp;</td></tr>
			</table>
		</td>
		</tr>
		</table>
		<!-- END: primary-content -->

	</div>
	<!-- END: content-wrapper -->

	<?php include('inc/footer.inc.php'); ?>
</div>
<!-- END: main -->
[/code]

I’m confused… Normally, an unsubscribe link simply takes the email address that was sent to it, handles saving the data to the database and displays a message that says “You have been removed from our mailing list!”. You do not want the user to have to retype the email address in and submit another form. That would just be annoying to the user.

So, fist, get rid of the Javascript stuff and the form stuff and make it just a simple PHP script.
It that script, just GET the email address (you already have that and it was inside of the unsubscribe link on the original email that the user clicked on), open your database, delete their info or if you want to keep their data for future use, just make it not-mailable so no further emails will be sent. Lastly, echo back a small page with your company’s header/footer and a simple “You have been removed, etc” message in the middle. (No links or menu buttons needed as they don’t want to be there.)

Did that make sense? Hope so, Good luck…

It does make sense however this page is used for other mailing campaigns in which the mailer does not have the ability to inject the users email address. Thus the need for a general unsubscribe page in which if the url is populated with the email it will automatically be inputted to the form and they simply click submit, or the user can manually input an email address and click submit.

Well, not sure what you need then, but, this code:

               function checkform ( form )
                 {
                    // ** START **    
                    if (form.email.value == "") {
                       alert( "Please enter your email address." );
                       form.email.focus();
                       return false ;
                     }
                       // ** END **
                       return true ;
                 }

Should be more like this:

            function checkform ( form )
                     {    
                       // ** START **
                       if (form.email.value == "") {
                         alert( "Please enter your email address." );
                         form.email.focus();
                         return false ;
                       }
                     else
                       {
                       // ** END **
                       return true ;
                       }
                   }

And, of course this will NOT post as there is no post code anywhere. The submit button cancels the form’s posting by switching it to the Javascript, so you will have to add the submitting of the form there. It would be done with this type of JS command: document.forms[“myform”].submit();
Of course, you need to set the ID=“myform” in the tag for this to work…

Hope that is what you were asking for… Good luck…

All of the POST data is in a separate doc, view code referencing insert.php. all db info is contained there.

?Bump?

Well, I finally figured it out… This was the code snip I was missing:

Email: <input type="text" name="email" value="<?php echo $_GET['email']; ?>" />

Specifically the info after the ‘value’ variable.

Ernie, thanks for your help. I realize I may have not been as specific as necessary in my question.

Great! Always nice when a puzzle problem is solved! I was gone for awhile, so never got back to your code… Happy you solved it… CYA in the bitstream…

Sponsor our Newsletter | Privacy Policy | Terms of Service