473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

May 12 '06 #1
7 1902
>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?


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
May 12 '06 #2
On Fri, 2006-05-12 at 10:21 -0700, bo********@gmail.com wrote:
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


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"> ...

May 12 '06 #3
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?

May 13 '06 #4
bo********@gmail.com wrote:
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?


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.
js*******@attglobal.net
==================
May 13 '06 #5
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?

May 13 '06 #6
bo********@gmail.com wrote:
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?


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.
js*******@attglobal.net
==================
May 14 '06 #7
On Sun, 2006-05-14 at 04:07 -0400, Jerry Stuckle wrote:
bo********@gmail.com wrote:
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?


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.


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.

May 14 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Philip Ronan | last post by:
OK, here's my 2p worth: === Q. Why am I getting the error message 'Headers already sent'? A. PHP produces this error message when you try to set a header for a web page after you have already...
3
by: sam | last post by:
Hello Group, Havent had luck posting it to microsoft.public.dotnet.framework.aspnet.datagridcontrol group. Excuse me for the cross posting. I have a datagrid which needs to be split into multiple...
71
by: Christopher Benson-Manica | last post by:
At what point was the .h dropped from the STL headers? I just had a discussion yesterday with my boss, who said he wanted .h on all the STL includes, despite me protesting that it was not...
1
by: stuart | last post by:
Hi, Can anybody tell me if it is possible to add your own headers through this class. The documenttion seems to be a bit ambiguous, for example the overview of the methods says Specifies the...
3
by: Jacky | last post by:
hi, I am trying to view the custom headers in an ASP.NET page. I am able to view all the standard headers using the method Request.Headers.Get(). But if i set a custom header using...
1
by: Ale News | last post by:
Hi to All.. I must add some custom headers HTTP and then i would to read them.. I used the AppendHeader Method to add my headers but when i try to read the headers i can't see my custom ones.....
2
by: fhtino | last post by:
Hello, I'm trying to create an email message with particular headers. A piece of code: SmtpClient smtp = new SmtpClient("192.168.x.y"); MailMessage msg = new MailMessage("from@xxxxxxx",...
5
by: Milos Prudek | last post by:
I perform a XML-RPC call by calling xmlrpclibBasicAuth which in turn calls xmlrpclib. This call of course sends a HTTP request with correct HTTP headers. The response is correctly parsed by...
4
by: sadieslc | last post by:
I'm working on a PHP script, and the info from the form shows up in the headers of the email that I receive, but it doesn't show up in the body of the email. Can you please help me figure out what...
6
Markus
by: Markus | last post by:
Things to discuss: Headers What are they? What does PHP have to do with headers? Why can they only be sent before any output? Common causes
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.