Re: PHP Session variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mar 27, 2007, at 9:17 AM, Chris Carter wrote:


Hi,

I have retrieved 4 values from database. Out of which 3 are displayed on the same page and one variable, which is email address, needs to be carried to the next page through a hyper link, the next page is actually a web form. I can do this by either transferring that variable through query string or
through session.

Now the next page which is a web form is connected to a file that sends
email using php email functionality.

The problem I am having is just sending this $email variable from page one to the web form. Once it reaches the web form, I need to again pass it to the file that has php email functionality. How to send the variable across
these pages.

I tried:
On Page 1:

<?
$query="SELECT val1, val2, val3, email FROM table WHERE no= '$no'";

$result=mysql_query($query);
$num=mysql_numrows($result);

mysql_close();
$1=mysql_result($result,$i,"1");
$2=mysql_result($result,$i,"2");
$3=mysql_result($result,$i,"3");
$email=mysql_result($result,$i,"email");
session_start();
session_register ("tamma");	
$HTTP_SESSION_VARS ["tamma"] = $email;
?>



On the webform:

<?
	$HTTP_SESSION_VARS ["email"] = $email;
	
?>


on the php email page it's like this:

<?
  $name = $_REQUEST['name'] ;
  $emailid = $_REQUEST['emailid'] ;
  $subject = $_REQUEST['subject'] ;
  $message = $_REQUEST['message'] ;
  $email = $_REQUEST['email'] ;

  mail( $email, $name, $message, "From: $emailid" );
  header( "Location: thankYouContact.php" );
?>


Please advice a work around for this if I am doing it wrong. I know I am.

On the page that generates your webform:

<input name="email" type="text" value="<?php $HTTP_SESSION_VARS ['tamma'] ?>">

Also, changing to using the $_SESSION superglobal array instead of $HTTP_SESSION_VARS will save you a bit of typing.

erik jones <erik@xxxxxxxxxx>
software developer
615-296-0838
emma(r)




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux