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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validate Form and give user feedback

Status
Not open for further replies.

rvr1

Programmer
Feb 6, 2004
16
NL
Hi,

This is my first PHP web app and I am I getting stuck with this:

I have a site where the user logs in under a session. Once logged in, there is a web form that has to be filled out. I have a script that validates the input, but I am having problems giving feeback to the user.

What I have done (hope this is enough info):

I use the 'post' action on the form.
This calls the php script that validates the input.
Using the echo command, I give feedback as to what fields have not been filled in correctly.

What I wish to do then is either:

i. Have the form re-displayed under the error message so that the user can modify it.

ii. Have a way to get back to the form with the input data still shown so that the user does not have to re-input all data.

I tried just writing include("nameofformfile.php"); under the echo statement that gives the error, but I get the error message:

Warning: Cannot send session cache limiter - headers already sent.

I hope that makes sense.

As I said, this is my first web application and I would really appreciate some help.

Cheers,

Rob
 
1. Warning: Cannot send session cache limiter - headers already sent means that something has already been sent to the output stream before the header() command which is implicit in session_start(). Even a single space at the top of the file can cause this.

2. I suggest you post to the same script that initially brings up the form. If the form is static I'd consider making it into a template with placeholders that allow for re-display of values and errors. If you don't want to go the template way just produce the necessary HTML with print statements. Your solution (i) is better.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top