View Single Post
  #6 (permalink)  
Old 07-14-2005, 03:58 PM
ChrisRC ChrisRC is offline
WebProWorld Pro
 
Join Date: Mar 2004
Location: Pittsburgh, PA, USA
Posts: 109
ChrisRC RepRank 0
Default

Quote:
Originally Posted by ozchris
Ok. So I'll goto a new page when successful, and start by validating in php. (Will try javascript validation when I've got this right).
[...]
Is this how to structure it?
Not quite. I think you're a little confused about the server-sidedness of PHP. Any validation that takes place before the form is submitted must be done on the client - that's where JavaScript comes in. So for the server-side, PHP portion, it would be more like:

The form is submitted
if (isset($submit_button)){
for each field in form{
if !validate(field){
generate a form with entered values pointing out where they messed up - or redirect back to form page with data on what they entered and how they messed up.
}
}
if send(email){
Generate Success page
}else{
Generate Error Page
}
}
Quote:
I'm learning PHP from a QuickStart book at home, so haven't been able to look over the shoulder of people coding PHP nicely.
Books are great, but don't forget there's a vast amount of info and code examples online too.

Quote:
When I re-enter formpage.php upon actioning the form, will I run into the problem that the fields entered will be reset to blank?
Yes. You'll have to use PHP to generate the form with the entered values.

Quote:
All this validation code at the top is so search-engine unfriendly, too.
It isn't. The PHP validation code is processed on the server and isn't visible to search engines at all.
Reply With Quote