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:
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.
PHPJavaScriptJoomla
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
session_start();
set session variables as
$_SESSION['userid'] ="548713";
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?
Simply start pages with
session_start();
set session variables as
$_SESSION['userid'] ="548713";
for detailed documentation please refer to
http://www.php.net/manual/en/features.sessions.php
http://www.php.net/manual/en/book.session.php