Avatar of Jonathan Greenberg
Jonathan Greenberg
Flag for United States of America asked on

How to get form data after php redirect

I have a php page in a web app I'm developing within Joomla that contains a form. The form action points somewhere (I'm not sure to which actual page), then it redirects to my new page. On my new page, I need access to the form values, but they are not accessible via $_POST. I assume this is because we're arriving at my new page due to a redirect rather than the form action.

I can edit the form and the page it's on pretty much however I like, but because this is all happening within a Joomla extension, I need to avoid getting in the way of the form action. The form action looks like this:

action="<?php echo JRoute::_( 'index.php?option=com_ajaxregistration' ); ?>" method="post"

I suppose I could add to it, but I'm not sure exactly how I would do that or how that might benefit me.

I can't figure out how to access the form data on my new page. One method that occurs is to save the values to a session, but I don't know how to do this from the same page that the form is on. Maybe by adding some javascript to the submit button? Or to the textfield onblur events? Or is it time for me to learn AJAX?

How can I make this form data accessible on my new page? Really need help with this one. Thanks.

Avatar of undefined
Last Comment
Jonathan Greenberg

8/22/2022 - Mon
Erdinç Güngör Çorbacı

You can use sessions for globalizing variable data across pages.

Simply start pages with

set session variables as
$_SESSION['userid'] ="548713";

for detailed documentation please refer to
Jonathan Greenberg

Thanks. I've been trying to do this, but what is the triggering event to save the data to the session?

For example, let's say I have session_start(); at the tops of my pages. I then have, on my first page, a form. Let's say one of the fields is 'lastname'. The user fills in 'lastname', then clicks submit. How do I get the value of 'lastname' to save to the session at this point?
Erdinç Güngör Çorbacı

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jonathan Greenberg

erdincgc, thanks for your help. I actually figured out another way to go, but everything you said was on the money.

Thanks again.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes