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

Required fields on a form-PHP

Status
Not open for further replies.

BettyJo50

Technical User
Apr 25, 2002
47
US
HI,

I have a form that finally works. When you submit the form it passes the information and then brings up a "Thank you" page. I now need to make some of the fields "required". I am having problems with figuring out the code on how to accomplish this. Can someone please help me?

THANK YOU!!! :)
 
What I do in cases like this is create a PHP script which produces an HTML form that submits back to the script itself.

The structure of the script is something like:

if (data was submitted)
{
check the input;

if (all required fields there)
{
process data;
show thankyou page;
}
else
{
show input form with fields pre-populated with values from submitted fields and appropriate error message(s);
}
}
else
{
show blank input form;
}


The two places where I am outputting the HTML form use a single user-defined function to produce the output. That function produces the form, including any necessary error messages, and sets the "value" attributes of the fields either to be blank (if this is the first run of the script and there was no data submitted) or set to the values submitted from a form produced by an earlier run of the script. Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top