Posted on 2004-11-05
Last Modified: 2006-11-17
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!

Question by:plannett
    LVL 20

    Expert Comment

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

    Expert Comment

    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 :
     $var_name = "value";
    Second script :
     echo $var_name;

    2) with $_SESSION
    First script :
     $_SESSION['var_name'] = "value";
    Second script :
     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')); ?>" />


    Author Comment

    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.

    LVL 20

    Accepted Solution

    I don't think session variables would carry into the perl script (soupemail).  You need to include the data as POST variables.  While it will be in the same session, I don't think soupemail is designed to take its values from SESSION vars.  So you'll need to include them in the post data being sent.  If you don't want the user to see them, use: "<INPUT type="hidden" value='your value'>

    The manual seems to suggest that you can use $cookie_* for cookies (e.g. not $x but $cookie_x to get to the cookie x).  You might be able to use $cookie_ for session variables. g/l.

    (from the manual):
    If you want to check on cookies, prefix the cookie's name with $cookie_.
    LVL 2

    Expert Comment

    just user your own PHP mail function

    $_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'; }

    LVL 25

    Expert Comment

    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:

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now