Page 1 of 1

How to back previous page with values just entered

Posted: Thu Nov 01, 2007 3:35 am
by arupcse
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.

Re: How to back previous page with values just entered

Posted: Sat Nov 03, 2007 4:35 pm
by lobos
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

Re: How to back previous page with values just entered

Posted: Sat Jan 26, 2008 7:59 pm
by davidannis
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

Re: How to back previous page with values just entered

Posted: Sat Jan 26, 2008 8:28 pm
by davidannis
Never mind:  Problem solved.  In case anyone else wants to know, I used:

Code: Select all

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


David

Re: How to back previous page with values just entered

Posted: Sat Jan 26, 2008 8:46 pm
by lobos
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

Re: How to back previous page with values just entered

Posted: Sun Jan 27, 2008 12:49 am
by davidannis
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/

Re: How to back previous page with values just entered

Posted: Sun Jan 27, 2008 1:48 am
by lobos
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