[PHP] Redirect then error message to user

2004-10-22 Thread Stuart Felenstein
I'm not quite sure how to get an error message to
print out after a redirect.  I know it's possible.
Now page1 moves to page2, check below is on page2
If I leave it on page2 (without redirect), it prints
error to user fine.  Once it redirects no print.  
I also tried leaving it on form1, at the top it won't
work, since the variables haven't been set yet.  
Not sure how to let it post form 1 to form 1 check and
then on success move to form 2.



 {
  // valid - next -
   }
   else
   {
header(Location: http://www.xx.com/page1.php;
);
print You have errors;
exit;
   }
  
  }
?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Redirect then error message to user

2004-10-22 Thread Jay Blanchard
[snip]
   {
header(Location: http://www.xx.com/page1.php;
);
print You have errors;
exit;
   }
  
  }
[/snip]

You either need to carry info about the error in a session variable or
url string or something...above your redirect happens before any error
can be sent to the browser

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Redirect then error message to user

2004-10-22 Thread Stuart Felenstein
Now why didn't I think of that ! Thank you Jay!

Stuart
--- Jay Blanchard
[EMAIL PROTECTED] wrote:

 [snip]
{
 header(Location:
 http://www.xx.com/page1.php;
 );
 print You have errors;
 exit;
}
   
   }
 [/snip]
 
 You either need to carry info about the error in a
 session variable or
 url string or something...above your redirect
 happens before any error
 can be sent to the browser
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Redirect then error message to user

2004-10-22 Thread Jason Wong
On Saturday 23 October 2004 01:25, Stuart Felenstein wrote:
 I'm not quite sure how to get an error message to
 print out after a redirect.  I know it's possible.

It's not possible. Think about it. How *can* you print something out when 
you've already told the browser to go somewhere else? BTW you ought to have 
an exit statement after the header() statement, some browsers will get 
confused if you continue printing stuff after a redirect.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Hey, diddle, diddle the overflow pdl
To get a little more stack;
If that's not enough then you lose it all
And have to pop all the way back.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Redirect then error message to user

2004-10-22 Thread Stuart Felenstein
This isn't working: 
Page2 (after page1 has been posted):

   else
   {
  $_SESSION['er'] = 'Please make sure to fill in all 3
corresponding values .';
header(Location:
http://www.x.com/TestMulti4a.php; );
exit;
   }
  
  }

Page1:
Opening after session_start

$_SESSION['er'] = $_POST['er'];

Then below in form area:

print $er; (tried also echo)

Am I do something wrong ?

Stuart

--- Jay Blanchard
[EMAIL PROTECTED] wrote:

 [snip]
{
 header(Location:
 http://www.xx.com/page1.php;
 );
 print You have errors;
 exit;
}
   
   }
 [/snip]
 
 You either need to carry info about the error in a
 session variable or
 url string or something...above your redirect
 happens before any error
 can be sent to the browser
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Redirect then error message to user

2004-10-22 Thread Jason Wong
On Saturday 23 October 2004 02:38, Stuart Felenstein wrote:
 This isn't working:
 Page2 (after page1 has been posted):

else
{
   $_SESSION['er'] = 'Please make sure to fill in all 3
 corresponding values .';

If you want keep changes to any session variables (so that they're available 
on subsequent pages) you need to:

  session_write_close()

before you redirect.

 header(Location:
 http://www.x.com/TestMulti4a.php; );
 exit;
}

   }

 Page1:
 Opening after session_start

 $_SESSION['er'] = $_POST['er'];

 Then below in form area:

 print $er; (tried also echo)

 Am I do something wrong ?

What are you trying to do here?
Is 'Page1' == TestMulti4a.php?
Are you trying to display $_SESSION['er'] as set in Page2?
If so why are you assigning $_POST['er'] to $_SESSION['er']? All you need to 
do is echo $_SESSION['er'].

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
A witty saying proves nothing.
-- Voltaire
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Redirect then error message to user

2004-10-22 Thread Stuart Felenstein
Sorry, all fixed now! 

Thank you for the help!

Stuart

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Redirect then error message to user

2004-10-22 Thread Stuart Felenstein
See below:
--- Jason Wong [EMAIL PROTECTED] wrote:


 What are you trying to do here?
 Is 'Page1' == TestMulti4a.php?
 Are you trying to display $_SESSION['er'] as set in
 Page2?
 If so why are you assigning $_POST['er'] to
 $_SESSION['er']? All you need to 
 do is echo $_SESSION['er'].
 

Yes Page1 - TestMulti4a
So slightly changed and I thought it was working,
seems TestMulti4a (page1) displays the error when I go
to it directly (before input)

So on Page2 I have:
else
   {
   $_SESSION['oops'] = Use all 3 fields to set a
skill;
  header(Location:
http://www.lurkingforwork.com/TestMulti4a.php; );
exit;
   }
  
Page1:
?php print $_SESSION['oops'] ?

I even logged out of the session, thinking I was now
carrying it through the session. 

Stuart



 
 Jason Wong - Gremlins Associates -
 www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet
 Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 A witty saying proves nothing.
   -- Voltaire
 */
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Redirect then error message to user

2004-10-22 Thread Stuart Felenstein
The only problem I'm having here is that if a user
goes backwards, the error from the session variable
will show up.  I put an unset $.. underneath the
echo but that seems to have no effect.


Stuart
--- Stuart Felenstein [EMAIL PROTECTED] wrote:

 See below:
 --- Jason Wong [EMAIL PROTECTED] wrote:
 
 
  What are you trying to do here?
  Is 'Page1' == TestMulti4a.php?
  Are you trying to display $_SESSION['er'] as set
 in
  Page2?
  If so why are you assigning $_POST['er'] to
  $_SESSION['er']? All you need to 
  do is echo $_SESSION['er'].
  
 
 Yes Page1 - TestMulti4a
 So slightly changed and I thought it was working,
 seems TestMulti4a (page1) displays the error when I
 go
 to it directly (before input)
 
 So on Page2 I have:
 else
{
$_SESSION['oops'] = Use all 3 fields to set a
 skill;
   header(Location:
 http://www.lurkingforwork.com/TestMulti4a.php; );
 exit;
}
   
 Page1:
 ?php print $_SESSION['oops'] ?
 
 I even logged out of the session, thinking I was now
 carrying it through the session. 
 
 Stuart
 
 
 
  
  Jason Wong - Gremlins Associates -
  www.gremlins.biz
  Open Source Software Systems Integrators
  * Web Design  Hosting * Internet  Intranet
  Applications Development *
  --
  Search the list archives before you post
  http://marc.theaimsgroup.com/?l=php-general
  --
  /*
  A witty saying proves nothing.
  -- Voltaire
  */
  
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit:
 http://www.php.net/unsub.php
  
  
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Redirect then error message to user

2004-10-22 Thread Brent Baisley
You can pass the error in the redirect URL:
header(Location: http://www.xx.com/page1.php?errmsg=You missed 
some stuff)

On your main page you just check if there is an errmsg to be displayed:
if(isset($_GET['errmsg'])) {
echo $_GET['errmsg'];
}
That a simplified version obviously. But that's the concept.
I design all my pages so that one file handles display, edit, 
validation and save. Then I don't have to worry about going back and 
forth between pages, doing redirects or retaining data through session 
variables. Most important, the user doesn't lose what they already 
entered just because they missed a field.

On Oct 22, 2004, at 3:58 PM, Stuart Felenstein wrote:
The only problem I'm having here is that if a user
goes backwards, the error from the session variable
will show up.  I put an unset $.. underneath the
echo but that seems to have no effect.
Stuart
--- Stuart Felenstein [EMAIL PROTECTED] wrote:
See below:
--- Jason Wong [EMAIL PROTECTED] wrote:

What are you trying to do here?
Is 'Page1' == TestMulti4a.php?
Are you trying to display $_SESSION['er'] as set
in
Page2?
If so why are you assigning $_POST['er'] to
$_SESSION['er']? All you need to
do is echo $_SESSION['er'].
Yes Page1 - TestMulti4a
So slightly changed and I thought it was working,
seems TestMulti4a (page1) displays the error when I
go
to it directly (before input)
So on Page2 I have:
else
   {
   $_SESSION['oops'] = Use all 3 fields to set a
skill;
  header(Location:
http://www.lurkingforwork.com/TestMulti4a.php; );
exit;
   }
Page1:
?php print $_SESSION['oops'] ?
I even logged out of the session, thinking I was now
carrying it through the session.
Stuart


Jason Wong - Gremlins Associates -
www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet
Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
A witty saying proves nothing.
-- Voltaire
*/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit:
http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Redirect then error message to user

2004-10-22 Thread Stuart Felenstein
Brent - Thank you I will try that method.

Can you elaborate more on below. I take it to mean you
have one page/script that your pages are going to do
all the checks.  

This form is 5 pages long.  So I chose session
variables just to keep it neat and maybe, more
secure.  

Stuart
--- Brent Baisley [EMAIL PROTECTED] wrote:

 I design all my pages so that one file handles
 display, edit, 
 validation and save. Then I don't have to worry
 about going back and 
 forth between pages, doing redirects or retaining
 data through session 
 variables. Most important, the user doesn't lose
 what they already 
 entered just because they missed a field.
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Redirect then error message to user

2004-10-22 Thread Graham Cossey
I think what Brent is suggesting is a single script that will handle the
display and processing of all 5 form 'pages'. The code below is just to give
an idea of how I think the 'flow' could go, don't go copying the code and
expect anything (positive) to happen !!


if(!$_POST['step'] || $_POST['step']=='0')
{
  // Display form 1 or call appropriate function/method
  if ($_SESSION['errmsg'])
echo $errmsg;

  form  action=$PHP_SELF?step=1

}
if($_POST['step']=='1')
{
  // Validate form 1 or call appropriate function/method
  if (error found) {
$errmsg = ul;
$errmsg .= li  Field One is required /li;
// etc etc
$_SESSION['errmsg'] = $errmsg;
  }
  // Not sure about the following line ??
  Header(Location: http://mysite.com/path/to/myself?step=2;);
}

if ($_POST['step']=='2')
{
  ... etc...


Graham

 -Original Message-
 From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
 Sent: 22 October 2004 21:55
 To: Brent Baisley
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] Redirect then error message to user


 Brent - Thank you I will try that method.

 Can you elaborate more on below. I take it to mean you
 have one page/script that your pages are going to do
 all the checks.

 This form is 5 pages long.  So I chose session
 variables just to keep it neat and maybe, more
 secure.

 Stuart
 --- Brent Baisley [EMAIL PROTECTED] wrote:

  I design all my pages so that one file handles
  display, edit,
  validation and save. Then I don't have to worry
  about going back and
  forth between pages, doing redirects or retaining
  data through session
  variables. Most important, the user doesn't lose
  what they already
  entered just because they missed a field.
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php