Jump to content

Passing variables to a 3rd page


bravo14

Recommended Posts

Hi

 

I have a form and the values are passed to page subscribe.php

 

If the one value is set to unsubscribe, then subscribe.php will redirect to unsubscribe.php, when I go to unsubscribe.php I have lost the variables.  Below is the code for unsubscribe.php

 

<?php
include_once('includes/connect.php');
$email=$_POST['form_email'];
$name=$_POST['form_name'];
$status=$_POST['form_subscribe2'];
echo('Status: '.$status);
$result=('SELECT * FROM `email_table` where `email`="'.$email.'"');
echo("Query: ".$result);
$check=mysql_query($result);
if(mysql_num_rows($check)==0)
{
echo('The email address '.$email.' is not subscribed to the Maypole Juniors newsletter');
}
else
{
$sql=('DELETE from `email_table` where `email` ="'.$email.'"');
if(!mysql_query($sql,$con))
				{
					die('Error: '.mysql_error());
				}
				else
				{
					echo($sql.'<br/>'.$name.' who has '.$email.' as their email address has successfully subscribed to the Maypole Juniors newsletter');
				}
}
?>

 

The redirect code from subscribe.php is

 

<?php

if($_POST['form_subscribe2']=="unsubscribe")

{

header ("Location: unsubscribe.php");

}

?>

 

 

How can I get the values to pass to unsubscribe.php?

Link to comment
Share on other sites

There are two easy options. 1, just do all of the work in subscribe.php, both subscribing and unsubscribing. 2, pass the variables in the url uinsg key=>value parameters, and then pull them out using the $_GET array. i.e.:

header ("Location: unsubscribe.php?email=".$email_address."value2=".$value2);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.