Jump to content

post variable to a new page


jlodwick

Recommended Posts

I currently have a php form that asks for first name, last name and email address then when they click submit it sends me an email with this information.  I also have a javascript that pops up a window saying their message was sent with an ok button that redirects them back to the main page.  I'd like to change this to redirect them to a new php page with a certificate with their name on it taken from the previous php form (but still email me the information).  My form action currently points back to the same php page for verification of information (like valid email address, etc.) so I can't point that to a new page.  Is there any way to do this?  The variables I have for the first name and last name are just $firstname and $lastname.

Link to comment
Share on other sites

From the research I did before I did this post I thought maybe that was what I needed to do but when I tried it, it didn't work.  I tried to just echo the variable on the next page and the page is just blank.  Below is my code for this that I tried.  The session_start() is also used for a captcha I'm using from "securimage" so hopefully that isn't conflicting somehow.

 

first page:

<?php

session_start(); // this MUST be called prior to any output including whitespaces and line breaks!

$_SESSION['firstname2'] = $var_value;

?>

 

second page:

<?php

$var_value = $_SESSION['firstname2'];

echo "$var_value";

?>

 

Link to comment
Share on other sites

Ok I got it working for one variable but I can't get it working for two.  I've tried both of the following without success.

 

first page:

<?php

session_start(); // this MUST be called prior to any output including whitespaces and line breaks!

$_SESSION['firstname2 lastname2'] = $var_value;

?>

 

second page:

<?php

session_start();

$var_value = $_SESSION['firstname2 lastname2'];

echo "$var_value";

?>

 

 

and

 

first page:

<?php

session_start(); // this MUST be called prior to any output including whitespaces and line breaks!

$_SESSION['firstname2'] = $var_value1;

$_SESSION['lastname2'] = $var_value2;

?>

 

second page:

<?php

session_start();

$var_value1 = $_SESSION['firstname2'];

$var_value2 = $_SESSION['lastname2'];

echo "$var_value1" "$var_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.