How to back previous page with values just entered

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Forum rules
Post Reply
arupcse
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Mon Oct 29, 2007 6:38 am

How to back previous page with values just entered

Post by arupcse » Thu Nov 01, 2007 3:35 am

currently i am working with login forum (components/com_register)
Here when any one register as new user then if the username is already entered then currently a message is showing 'This username/password already in use. Please try another.' and returning the previous page all the fields left blank. I want such that when it will return the previous page then all the fields without username and password will be filled by the values just entered.

thanks.

User avatar
lobos
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Wed Jul 19, 2006 3:33 pm
Location: Sao Paulo, Brasil
Contact:

Re: How to back previous page with values just entered

Post by lobos » Sat Nov 03, 2007 4:35 pm

I guess there are a few ways to do this... you could always save the get / post variables to a session var on the error page, something like this:

at the top of the page:

session_start();
$_SESSION['formvalues'] = $_REQUEST; //this will save all post and get variables.

Then you hack the registration form and add the variables to the form values like this:

//top of page
session_start();
extract($_SESSION['formvalues']); //this extracts the $_SESSION['formvalues'] array into variables - eg $_SESSION['formvalues']['myvar'] becomes $myvar;

//hack the form values
" />

-Lobos
Respect and honour, sempre isso, the tribal way, the only way.
http://en.wikipedia.org/wiki/Tribes_Vengeance

davidannis
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sat Jan 26, 2008 7:48 pm
Contact:

Re: How to back previous page with values just entered

Post by davidannis » Sat Jan 26, 2008 7:59 pm

When I use the code

Code: Select all

  $_SESSION['formvalues'] = $_REQUEST; 


It puts the values into an array within the $_session array, so then when I want to get a value out I need to do something like:

Code: Select all

echo "risk5 : ",$_SESSION['formvalues']['risk5'];


Is there an easy way to expand the fromvalues array as I put it into the $_session array so that  I can just use $_Session['risk5']?

Thanks,
David
http://www.ignoranceoffsets.com

davidannis
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sat Jan 26, 2008 7:48 pm
Contact:

Re: How to back previous page with values just entered

Post by davidannis » Sat Jan 26, 2008 8:28 pm

Never mind:  Problem solved.  In case anyone else wants to know, I used:

Code: Select all

$_SESSION = array_merge($_SESSION,$_REQUEST);


David

User avatar
lobos
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Wed Jul 19, 2006 3:33 pm
Location: Sao Paulo, Brasil
Contact:

Re: How to back previous page with values just entered

Post by lobos » Sat Jan 26, 2008 8:46 pm

davidannis wrote:Never mind:  Problem solved.  In case anyone else wants to know, I used:

Code: Select all

$_SESSION = array_merge($_SESSION,$_REQUEST);


David



be careful with this, it has security nightmare written all over it... one could set any session variable from the url, well maybe... not sure... but be careful

-Lobos
Respect and honour, sempre isso, the tribal way, the only way.
http://en.wikipedia.org/wiki/Tribes_Vengeance

davidannis
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sat Jan 26, 2008 7:48 pm
Contact:

Re: How to back previous page with values just entered

Post by davidannis » Sun Jan 27, 2008 12:49 am

I am just using the $_session variable to store values that I collect on a few consecutive screens so that I can use them to do calculations and create a report.  The program will be similar to one that was written by a professional programmer for me at http://www.freevaluationsonline.com to do business valuations.  He hard coded the name of every variable and I figured there had to be a better way.

Perhaps it's because I'm a real newcomer to this language, but I don't see the risk.  As far as I can tell the $_SESSION variable only contains a SESSION ID and the values that were input on the various screens, which the user picks anyway.  Am I wrong and there's something else in the $_SESSION array or something that's not in it and really shouldn't be.  Is it a Joomla related security issue?  Perhaps I should have posted to PHPBuilder.com, but I found the answer here first.

Thanks,
David
http://www.ignoranceoffsets.com/

User avatar
lobos
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Wed Jul 19, 2006 3:33 pm
Location: Sao Paulo, Brasil
Contact:

Re: How to back previous page with values just entered

Post by lobos » Sun Jan 27, 2008 1:48 am

Well I dunno for sure like I said, but I know for one of my components there are sessions that are set which, if compromised, could cause a significant risk, maybe other components could have problems as well. This is why it would be better to set the session in a sub-dimension of the sessions array as opposed to the root.

But anyway if no one knows the inner workings of your code it's probably not such a risk, but I just thought I would warn you.

-Lobos
Respect and honour, sempre isso, the tribal way, the only way.
http://en.wikipedia.org/wiki/Tribes_Vengeance


Post Reply