peterv12 said:
Phil,
I'm trying your 1B suggestion, but I'm a little confused. If I put the sql code in an include file, where should it go in the file?
Also, if the "action" is PHP_SELF, how does the form get processed before the sql include file? I think I need to find a PHP/HTML form tutorial, I don't want to keep bugging you with beginner questions.[/quote]
I'm assuming you mean: "where should it go in the file that has the form"?
If so then you need to put it where it will begin to
process the form.
for example (and this is the way I usuall do it):
[code
if(isset($_POST['process'])){
include("processingfile.php");
}
<form action="<?PHP echo $_SERVER['PHP_SELF']; ?>" method="POST">
...
<input type=submit name="process" value="Submit">
</form>
[/code]
What this does is it checks whether or not $_POST['process'] exists or is set by using the isset function. If it is set, then the form has been submitted, as the value from the submit button has been passed and a variable created for it.
It then just includes the file that holds all the processing code. So it does all the work.
This same file decides what to do after wards.
And then as a last tihng if the form was not submitted or its done processing, then it displays the form.
Now you can conditionalize the display of the form if you need to based on the result of the processing script.
The only thing is to check whether the form has been submitted before attempting to include the file if only to avoid errors related to non existent variables at the time. This is what postback is all about. Since everything is done in the same script, you need to check at what point in the flow you currently are.
jpadie posts uses the 1.A method. which I use if the processing is short and simple, and will not make future reading of the file too complex.
----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.