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
https://forums.phpfreaks.com/topic/164860-passing-variables-to-a-3rd-page/
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);

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.