Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old May 12th, 2006, 06:25 PM
bob.herbst@gmail.com
Guest
 
Posts: n/a
Default Headers??

I am writing a page with sessions. At the start of every page I check
to make sure that the user actually has a session by checking for some
SESSION variables. On one of my pages I have a form that is to add
guests for an event. I have no idea how many guests a particular member
is giong to bring and the number of guests is not limited. So to save
myself time I wrote a form that will allow you to add one guest and
then hit add guest. This will save that guest to the guest table in my
MySQL database but then I want to reload the page to have them add
another guest. The only problem I am having is that the only way I know
how to send the user to the page is using the header() function. This
is not working because I have already output data. Is there a better
way to do this so that I can one form and not have to have a form input
for guests up to 20?

Thanks

  #2  
Old May 12th, 2006, 07:05 PM
Gordon Burditt
Guest
 
Posts: n/a
Default Re: Headers??

>I am writing a page with sessions. At the start of every page I check[color=blue]
>to make sure that the user actually has a session by checking for some
>SESSION variables. On one of my pages I have a form that is to add
>guests for an event. I have no idea how many guests a particular member
>is giong to bring and the number of guests is not limited. So to save
>myself time I wrote a form that will allow you to add one guest and
>then hit add guest. This will save that guest to the guest table in my
>MySQL database but then I want to reload the page to have them add
>another guest. The only problem I am having is that the only way I know
>how to send the user to the page is using the header() function. This
>is not working because I have already output data. Is there a better
>way to do this so that I can one form and not have to have a form input
>for guests up to 20?[/color]

You get to output data *OR* redirect to a new page.
Only one will be displayed. Which do you want displayed?
If it's not going to be seen, don't output it.

You have several options:

- Output "guest added successfully", followed by the form to add another
guest.
- Output a page indicating the guest was added successfully, with a
"add another guest" button on it.
- Write a page which, if form data is provided stores it, then, whether
or not form data is provided, outputs another copy of the form
(which submits to itself).

Gordon L. Burditt
  #3  
Old May 12th, 2006, 08:55 PM
Scott
Guest
 
Posts: n/a
Default Re: Headers??

On Fri, 2006-05-12 at 10:21 -0700, bob.herbst@gmail.com wrote:[color=blue]
> I am writing a page with sessions. At the start of every page I check
> to make sure that the user actually has a session by checking for some
> SESSION variables. On one of my pages I have a form that is to add
> guests for an event. I have no idea how many guests a particular member
> is giong to bring and the number of guests is not limited. So to save
> myself time I wrote a form that will allow you to add one guest and
> then hit add guest. This will save that guest to the guest table in my
> MySQL database but then I want to reload the page to have them add
> another guest. The only problem I am having is that the only way I know
> how to send the user to the page is using the header() function. This
> is not working because I have already output data. Is there a better
> way to do this so that I can one form and not have to have a form input
> for guests up to 20?
>
> Thanks
>[/color]

Instead of using header(), why not have the form post to itself?

<?php
if (isset($_POST['guest'])) {
include('formProcessingCode.php');
}
?>

<form action="<?=$_SERVER['PHP_SELF']?>" method="post"> ...

  #4  
Old May 13th, 2006, 06:45 PM
bob.herbst@gmail.com
Guest
 
Posts: n/a
Default Re: Headers??

I have the form posting to itself now and the only problem is that when
I do the include function at the bottom it keeps the original table and
when the page reloads it puts it below the original table. I want the
whole page to reload not to include the new page below the old
page...do I need to use javascript or something to have the page reload
before using the include function?

  #5  
Old May 13th, 2006, 07:55 PM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: Headers??

bob.herbst@gmail.com wrote:[color=blue]
> I have the form posting to itself now and the only problem is that when
> I do the include function at the bottom it keeps the original table and
> when the page reloads it puts it below the original table. I want the
> whole page to reload not to include the new page below the old
> page...do I need to use javascript or something to have the page reload
> before using the include function?
>[/color]

Sounds like you need to check the $_POST parms and determine if you need to show
the original table (first time through) or not.

Javascript won't help you - it's executed on the client after the php has completed.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  #6  
Old May 13th, 2006, 10:15 PM
bob.herbst@gmail.com
Guest
 
Posts: n/a
Default Re: Headers??

The problem is that, if you add say 3 guests I have it so that you add
one guest at a time and that would mean that it would stack 3 tables on
top of each other by the time the person is done adding guests it would
be something like

No guest
Form

No guest
Guest1
Form

No Guest
Guest1
Guest2
Form

so on and so forth...is there any way to make it so only the most
recent table pops up and not the old ones?

  #7  
Old May 14th, 2006, 09:15 AM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: Headers??

bob.herbst@gmail.com wrote:[color=blue]
> The problem is that, if you add say 3 guests I have it so that you add
> one guest at a time and that would mean that it would stack 3 tables on
> top of each other by the time the person is done adding guests it would
> be something like
>
> No guest
> Form
>
> No guest
> Guest1
> Form
>
> No Guest
> Guest1
> Guest2
> Form
>
> so on and so forth...is there any way to make it so only the most
> recent table pops up and not the old ones?
>[/color]

And why would it do that? It should only put the last guest in there.

I think you need to go back and just think about the logic flow of your pages.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  #8  
Old May 14th, 2006, 04:25 PM
Scott
Guest
 
Posts: n/a
Default Re: Headers??

On Sun, 2006-05-14 at 04:07 -0400, Jerry Stuckle wrote:[color=blue]
> bob.herbst@gmail.com wrote:[color=green]
> > The problem is that, if you add say 3 guests I have it so that you add
> > one guest at a time and that would mean that it would stack 3 tables on
> > top of each other by the time the person is done adding guests it would
> > be something like
> >
> > No guest
> > Form
> >
> > No guest
> > Guest1
> > Form
> >
> > No Guest
> > Guest1
> > Guest2
> > Form
> >
> > so on and so forth...is there any way to make it so only the most
> > recent table pops up and not the old ones?
> >[/color]
>
> And why would it do that? It should only put the last guest in there.
>
> I think you need to go back and just think about the logic flow of your pages.
>[/color]

I agree with Jerry about rethinking your logic flow. Sounds like you
just need to do your form processing BEFORE sending any output. That
way, you can have your guest list completely compiled before displaying
it, removing the "No Guest" row when one or more guests have already
been submitted.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,338 network members.