[PHP] header(Location:blah...) - passing variables
Hi, I wonder if someone could tell me whether or not the following is possible? I have an HTML form which passes a username and password to a PHP script for validation. If either is not valid, I would like it to return to the previous page - carrying with it a variable plus the submitted form information... =-=-=-=-=-=-=-=-= if (strlen ($password1) 4 ) { $err = Password must be more than 4 characters long; header(Location:http://somelocation.php;); // ^-- at the location, the $err and form variables will be available exit; } =-=-=-=-=-=-=-=-= Is it possible to this without using an HTML form? Thanks very much in advance. - Best regards, Lee -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] header(Location:blah...) - passing variables
There are many different ways to do this ... 1. Have the same PHP script that validates generate the login page. This way the script always has the correct data and you don't need to pass anything. 2. Header(Location: login.php?err=$erruser=$userpass=$pass); This will work, but the bad password will be visible in the query string. 3. Start a session at the login page and register the variables you need to use on the login page. Jim Hi, I wonder if someone could tell me whether or not the following is possible? I have an HTML form which passes a username and password to a PHP script for validation. If either is not valid, I would like it to return to the previous page - carrying with it a variable plus the submitted form information... =-=-=-=-=-=-=-=-= if (strlen ($password1) 4 ) { $err = Password must be more than 4 characters long; header(Location:http://somelocation.php;); // ^-- at the location, the $err and form variables will be available exit; } =-=-=-=-=-=-=-=-= Is it possible to this without using an HTML form? Thanks very much in advance. - Best regards, Lee -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- Jim Musil - Multimedia Programmer Nettmedia - 212-629-0004 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] header(Location:blah...) - passing variables
Set the form receiver to $PHP_SELF. When data is posted (use $HTPP_POST_VARS to check if is) check it for correctness. If everything is ok, use Header(Location: work_for_authorized.php) otherwise show the current (i.e. login page) with $user, $pass available... Zliy PEs, http://www.zliypes.com.ua - Original Message - From: Lee Philip Reilly [EMAIL PROTECTED] To: PHP List [EMAIL PROTECTED] Sent: Tuesday, December 04, 2001 7:46 PM Subject: [PHP] header(Location:blah...) - passing variables Hi, I wonder if someone could tell me whether or not the following is possible? I have an HTML form which passes a username and password to a PHP script for validation. If either is not valid, I would like it to return to the previous page - carrying with it a variable plus the submitted form information... =-=-=-=-=-=-=-=-= if (strlen ($password1) 4 ) { $err = Password must be more than 4 characters long; header(Location:http://somelocation.php;); // ^-- at the location, the $err and form variables will be available exit; } =-=-=-=-=-=-=-=-= Is it possible to this without using an HTML form? Thanks very much in advance. - Best regards, Lee -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] header(Location:blah...) - passing variables
I cheat and just include the original form on error ... Almost all my input values are set to PHP variables in the form. The 1st time through none are set, so the values are blank. After submitting the form, I check for validity. If there are errors I mark the errors, generate an error string, and include the form. That way all previously typed in data remains in the form without me having to tell the user to hit the back button, and there's no horribly long URL string resetting all those values. There's a bit more work than that (using htmlspecialchars et al.) but if you start creating forms with error checking indication in mind it's really easy to do validation and redisplay if necessary. Mark C. Hi, I wonder if someone could tell me whether or not the following is possible? I have an HTML form which passes a username and password to a PHP script for validation. If either is not valid, I would like it to return to the previous page - carrying with it a variable plus the submitted form information... =-=-=-=-=-=-=-=-= if (strlen ($password1) 4 ) { $err = Password must be more than 4 characters long; header(Location:http://somelocation.php;); // ^-- at the location, the $err and form variables will be available exit; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] header(Location:blah...) - passing variables
My approach has been to pass an error code back to the original form. form.php: ?php print(form aciton=\formVerify.php\); print(a buncha form crap); if ($errcode==1) print (Your user id is wrong. You suck); if ($errcode==2) print (Your password is wrong. You really suck); print(/form); ? Then in formVerify.php: ?php ...error checking code... if (userID invalid) header(Location: form.php?errcode=1); if (password invalid) header(Location: form.php?errcode=2); else header(Location: goodpage.php); ? You could probably also use cookies to pass the error code back and forth, but that's probably overkill and unreliable. (Sorry if the pseudo-code I used above offends anyone with the use of the word suck; the futile job search has got me really annoyed right now.) At 10:25 AM 12/4/2001, Mark Charette wrote: I cheat and just include the original form on error ... Almost all my input values are set to PHP variables in the form. The 1st time through none are set, so the values are blank. After submitting the form, I check for validity. If there are errors I mark the errors, generate an error string, and include the form. That way all previously typed in data remains in the form without me having to tell the user to hit the back button, and there's no horribly long URL string resetting all those values. There's a bit more work than that (using htmlspecialchars et al.) but if you start creating forms with error checking indication in mind it's really easy to do validation and redisplay if necessary. Mark C. Hi, I wonder if someone could tell me whether or not the following is possible? I have an HTML form which passes a username and password to a PHP script for validation. If either is not valid, I would like it to return to the previous page - carrying with it a variable plus the submitted form information... =-=-=-=-=-=-=-=-= if (strlen ($password1) 4 ) { $err = Password must be more than 4 characters long; header(Location:http://somelocation.php;); // ^-- at the location, the $err and form variables will be available exit; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] Sliante, Richard S. Crawford http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford MSN: [EMAIL PROTECTED] It is only with the heart that we see rightly; what is essential is invisible to the eye. --Antoine de Saint Exupéry Push the button, Max! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] header(Location:blah...) - passing variables
It has been my idea to make a function, and pass the fields, then register a global feedback var and then check one by one each required field, or what ever you are trying to verify in the fields. function formCheck ($username,$password,$smellycat) { global $feedback, $username, $password; if (!$username) { $feedback .= Yo! This ain't right ... fix it!; return false; } blah blah blah ... --- Richard S. Crawford [EMAIL PROTECTED] wrote: My approach has been to pass an error code back to the original form. form.php: ?php print(form aciton=\formVerify.php\); print(a buncha form crap); if ($errcode==1) print (Your user id is wrong. You suck); if ($errcode==2) print (Your password is wrong. You really suck); print(/form); ? Then in formVerify.php: ?php ...error checking code... if (userID invalid) header(Location: form.php?errcode=1); if (password invalid) header(Location: form.php?errcode=2); else header(Location: goodpage.php); ? You could probably also use cookies to pass the error code back and forth, but that's probably overkill and unreliable. (Sorry if the pseudo-code I used above offends anyone with the use of the word suck; the futile job search has got me really annoyed right now.) At 10:25 AM 12/4/2001, Mark Charette wrote: I cheat and just include the original form on error ... Almost all my input values are set to PHP variables in the form. The 1st time through none are set, so the values are blank. After submitting the form, I check for validity. If there are errors I mark the errors, generate an error string, and include the form. That way all previously typed in data remains in the form without me having to tell the user to hit the back button, and there's no horribly long URL string resetting all those values. There's a bit more work than that (using htmlspecialchars et al.) but if you start creating forms with error checking indication in mind it's really easy to do validation and redisplay if necessary. Mark C. Hi, I wonder if someone could tell me whether or not the following is possible? I have an HTML form which passes a username and password to a PHP script for validation. If either is not valid, I would like it to return to the previous page - carrying with it a variable plus the submitted form information... =-=-=-=-=-=-=-=-= if (strlen ($password1) 4 ) { $err = Password must be more than 4 characters long; header(Location:http://somelocation.php;); // ^-- at the location, the $err and form variables will be available exit; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] Sliante, Richard S. Crawford http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford MSN: [EMAIL PROTECTED] It is only with the heart that we see rightly; what is essential is invisible to the eye. --Antoine de Saint Exupéry Push the button, Max! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] = dan mccullough Theres no such thing as a problem unless the servers are on fire! __ Do You Yahoo!? Buy the perfect holiday gifts at Yahoo! Shopping. http://shopping.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] header(Location:blah...) - passing variables
I'd recommend urlencoding those variables if you're going to do it that way, otherwise you may get some non-sense characters resulting in a bad URL. J Jim wrote: There are many different ways to do this ... 1. Have the same PHP script that validates generate the login page. This way the script always has the correct data and you don't need to pass anything. 2. Header(Location: login.php?err=$erruser=$userpass=$pass); This will work, but the bad password will be visible in the query string. 3. Start a session at the login page and register the variables you need to use on the login page. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] header(Location:blah...) - passing variables
In a revised scheme for a customer I'm doing # 3. User can come into any page, a bit of PHP at the top does this: starts session registers origin assigns PHP_SELF to $origin checks to see if another session var is set and directs to logon page if not if( !session_is_registered( member_id ) ) { header(Location: logon.php\n)}; Where they are logged on and member_id is set. There's nothing magic about member_id, it's simply a token and has no content. After authentication the user is returned, via a header command, like so: header(Location: $origin); If authentication fails they loop on the logon page, which has links to a registration and lost my password forms. The neatest part of this is that any page can be protected from unauthorized viewing merely adding a bout 6 lines of code at the top and saving it with a php rather than html extension. Regards - Miles Thompson http://www.cqagroup.ca At 12:47 PM 12/4/2001 -0500, Jim wrote: There are many different ways to do this ... 1. Have the same PHP script that validates generate the login page. This way the script always has the correct data and you don't need to pass anything. 2. Header(Location: login.php?err=$erruser=$userpass=$pass); This will work, but the bad password will be visible in the query string. 3. Start a session at the login page and register the variables you need to use on the login page. Jim Hi, I wonder if someone could tell me whether or not the following is possible? I have an HTML form which passes a username and password to a PHP script for validation. If either is not valid, I would like it to return to the previous page - carrying with it a variable plus the submitted form information... =-=-=-=-=-=-=-=-= if (strlen ($password1) 4 ) { $err = Password must be more than 4 characters long; header(Location:http://somelocation.php;); // ^-- at the location, the $err and form variables will be available exit; } =-=-=-=-=-=-=-=-= Is it possible to this without using an HTML form? Thanks very much in advance. - Best regards, Lee -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- Jim Musil - Multimedia Programmer Nettmedia - 212-629-0004 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]