Link to home
Start Free TrialLog in
Avatar of plannett
plannett

asked on

Session_Variables_Soupermail

Buenos Dias Amigos!

I have a multipage form, quite simple actually... a form (page 1), a summary page (page 2), and a thank you page (page 3). Passing variables from p1 to p2 is established, however, upon finalizing the order in p2 and sending all of the pages content (hidden fields, fields, session variables) the session variables get dropped.

They do not appear in my email template that arrives in my inbox. I am using soupermail, but i do not think that is the problem.

I notced, that in my summary page (p2), where I re-display the users in put (<?php $_POST['VAR_NAME']; ?>) in an actual, editable txtField, that gets submitted and processed correctly. But, if I simply redisplay the sess_var on the page, it does not get submitted.

Any ideas?

Adios Amigos!

PlannettF
Avatar of virmaior
virmaior
Flag of United States of America image

The session wouldn't follow through an e-mail... other than that, I'm not sure I can understand what you are asking.
Avatar of BenMorel
BenMorel

Maybe the session is not started in each script. Remember to use session_start() in EACH of them.

There's 2 ways to achieve it with sessions :
1) with session_register()
First script :
<?php
 session_start();
 session_register('var_name');
 $var_name = "value";
?>
Second script :
<?php
 session_start();
 session_register('var_name');
 echo $var_name;
?>

2) with $_SESSION
First script :
<?php
 session_start();
 $_SESSION['var_name'] = "value";
?>
Second script :
<?php
 session_start();
 echo $_SESSION['var_name'];
?>

Note: don't use both session_register() and $_SESSION in the same script.

You can also do it without sessions, with hidden fields :
<input type="hidden" name="var_name" value="<?php echo htmlentities(@$_POST['var_name']); ?>" />

Or, if magic_quotes_gpc is enabled on your server :
<input type="hidden" name="var_name" value="<?php echo htmlentities(stripslashes(@$_POST['var_name')); ?>" />

Regards,
Ben
Avatar of plannett

ASKER

Page 1 has session start and session is started on the second page. Third page does not require it, as it is simply a "Thank you" page.

All of the data I am seeking to submit exists in page 2. Remember, in my original post, i stated that page 1 is the form, page 2 is a summary of 1 and that everything carried over just fine.

I think where I am confused is: do session_variables get submitted to soupermail when the user hits the submit button?

Apparently not, because nothing carries over into the results of the script.

Page 3 is irrelevant, it's a success page that gets called from a hidden value in page 2.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of virmaior
virmaior
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
just user your own PHP mail function
http://br2.php.net/manual/en/function.mail.php

example:
<?
session_start()
$_SESSION['email_add'] = $_SESSION['email_add'];

$message = 'Thanks for shopping';

if (mail( $_SESSION['email_add'], "the subject", $message,
     "From: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
     "Reply-To: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
     "X-Mailer: PHP/" . phpversion())){
echo 'success on mail send';
}
else { echo 'error on sending mail'; }

?>
Avatar of Marcus Bointon
PHP's implementation of sessions will be different to what you'll find in Perl, so session vars will not be available to Perl if you created them from PHP - unless there is a PHP_Session package in CPAN somewhere?

mail() is worth avoiding, especially on Windows. Use phpmailer instead:

http://phpmailer.sourceforge.net/