[plug] HTTP return header?

Jason Belcher jas at whatever.iinet.net.au
Fri Jan 11 13:19:49 WST 2002


J Michael Gilks wrote:

>I am writing a site for Mater Dei College and on the login page I need to 
>validate entries on the form before submitting it to the database. Using the 
>onSubmit method of the form I check entries and if they are missing setfocus 
>to that entry then return false. This should stop the submit process, but it 
>doesn't. I get my error message box come up and then the form submits anyway.
>What I would like to do is include a header on the action page to redirect 
>back to the login page, with the information intact, if this error occurs.
>I am using Quanta as an IDE, with PHP scripting on an Apache server.
>I am sure there is an appropriate header as every browser has a back button 
>which works. I just can't find a reference.
>Can anyone help please.
>Love
>Mike.
>
You can do it using javascript by using onClick of the submit button 
instead of onSubmit of the form (I think, someone correct me if I'm wrong).

However, you're probably better off doing the validation on the 
server-side instead of client-side because if someone doesn't have 
javascript turned on or if they are intentionally trying to break your 
site (which will probably happen in a school situation if students have 
access to it) the server will accept any values it is given. Something 
like this in PHP on the page the data is being submitted to would do it:

if($formfield1 != "" && $formfield2 != "" ...)
{
    //do whatever happens on this page
} else
{
    //send them back to the original page, possibly with an error message
}



HTH
Jason





More information about the plug mailing list