Re: Function execution before page reload



Schmidty wrote:

On Jan 29, 9:58 am, "Schmidty" <schmi...@xxxxxxxxxxxxxxxx> wrote:

==================Jerry,
Thanks for your help on this. I am still learning the client/server
concepts with PHP as well as OOP so bare with me...

I understand what you have said and it makes sense. How would I update
the page with new information that is sent back from the database via
the server after clicking a 'submit' button? From what you are telling
me then, when the 'submit' button is pressed the script is re-
executed. In a function would I set the 'action' to a new page or use
the $_SERVER['PHP_SELF'] variable? Do I put an 'if' statement BEFORE I
send the page to the browser?

P. S. - I am using the Google Groups editor and it puts my replies at
the top of the page. I can put my reply at the bottom of the page if
this helps...

Jerry I think I figured it out!!!

I put two 'if' statements to check the form and then displayed the contents what was queried from the browser!
Here is what I did;

Example ===============================================

if (isset($_POST['approved']) and isset($_POST['approve'])){
$passapproval=$_POST['approve'];
if ($passapproval){
foreach ($passapproval as $userid){ $nu->approveApps($userid);}
} // end if
} // end if
$nu->checkApps();

End Example ============================================

This works great and it makes sense with your explanation of the pages being 'stateless'. Thanks for your help and hope to get more help from you in the future. :)

Schmidty


Hi, Schmidty.

Sorry for the delay in responding, but I had a hard disk crash and it took me several days to get it back up and running again. But thank $deity for backups! :-)

Yep, basically before you write your page, you have your PHP code check the $_POST (or $_GET) array to see if data has been sent. If so, process the data and then display the page. Otherwise, just display a blank page.

You could also have the data sent do a different page which processes it and redirects back to the original page (see the 'header' function). But I find that usually makes things more complicated and harder to manage.

Glad you got it. And again, sorry to take so long to respond.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.