jlodwick Posted April 19, 2012 Share Posted April 19, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/261224-post-variable-to-a-new-page/ Share on other sites More sharing options...
requinix Posted April 19, 2012 Share Posted April 19, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/261224-post-variable-to-a-new-page/#findComment-1338659 Share on other sites More sharing options...
jlodwick Posted April 19, 2012 Author Share Posted April 19, 2012 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"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/261224-post-variable-to-a-new-page/#findComment-1338835 Share on other sites More sharing options...
jlodwick Posted April 19, 2012 Author Share Posted April 19, 2012 I just realized I forgot to add session_start(); to my second page. It's working now. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/261224-post-variable-to-a-new-page/#findComment-1338838 Share on other sites More sharing options...
jlodwick Posted April 19, 2012 Author Share Posted April 19, 2012 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"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/261224-post-variable-to-a-new-page/#findComment-1338841 Share on other sites More sharing options...
jlodwick Posted April 19, 2012 Author Share Posted April 19, 2012 Nevermind. I was doing the echo command wrong. It's working now. Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/261224-post-variable-to-a-new-page/#findComment-1338847 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.