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
https://forums.phpfreaks.com/topic/261224-post-variable-to-a-new-page/
Share on other sites

Put the name and whatever else you may want into the session, then redirect to the certificate page. That page then uses the name and whatever else you put into the session to display the certificate.

 

Have you used sessions before?

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";

?>

 

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";

?>

 

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.