Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session errors

Status
Not open for further replies.

primate

IS-IT--Management
Jan 6, 2003
123
GB
I have an inital form that passes data to a second page using $_POST.

The second page is a form as well however the action attribute points to itself as a user may want to execute the form several times.

I need to pass some non-form data from first execution of the second form back to itself for the second/third etc. execution of the form so I can't use $_POST because its not form data.

I tried starting a session on the second form but this just produced errors and failed to start the session correctly.

I've now started the session on the first form however unless I call session_start() on the second form too I get Undefined variable: _SESSION on submission of the form data.

If I include session_start() on the second form too I get - "A session had already been started - ignoring session_start()" Is this normal or can I ignore it?
 
Simplify your code to <10 lines, then if the error isn't apparent to you, you have something significant and concise to post to the forum. Without seeing your code, there's no way we'll be able to figure out what you're doing wrong.
 
session_start() must be issued for session variables to be available to PHP. This can happen explicitly in your code, or by setting session.auto_start to 1 in php.ini


Don't say, "If I include session_start() on the second form" say "If I include session_start() on the second script". Your browser contacts a web server and asks for a PHP script. The server runs the PHP script, which then outputs HTML which may include HTML form tags. It's important to keep the two separate -- it can make debugging easier when your scripts get complex.

I'd check that second script to see whether it already has a session_start() invocation.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I consider myself duly chastised...... :)

I've managed to resolved the problem with a fresh pair of eyes this morning.
 
Please don't think I was chastizing.

I have seen an enormous number of people in this forum who get themselves into a programing bind with PHP simply because they don't have a clear picture of what happens in a web appliction. Many people who have console application programming experience tend to think in terms of the GUI and the application having constant communication and they think this extends to web applications.

Unfortunately, web applications are discontinuous. That simple paradigm fault can lead to trouble debugging an app. And I've found that getting folks to use more consistent vocabulary is often a good first step in understanding.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Yes OK, I'm not used to any kind of programming though, so I don't suffer from the delusion you describe, though having said that I suffer from many others, such as how sessions work for example :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top