Jump to content

Does the server call "isset" all the time?


Arbu

Recommended Posts

I've got some code which looks like this:

<?php


if (isset($_POST['username'],$_POST['first_name'],$_POST['surname'], $_POST['email'], $_POST['p'])) {
    // Sanitize and validate the data passed in...

in a file called register.inc.php. The only references to this file are

include_once 'includes/register.inc.php';

in the opening lines of a couple of other files.

What is puzzling is just how the php condition gets called. Is it called continuously, so that as soon as the variables have been set, it triggers? Or is it called when the page that includes it is loaded? Whatever, it doesn't seem to be called like a normal function. It all seems a bit mysterious and unexplained. Can anyone help me out?

Thanks.

Link to comment
Share on other sites

It is called as soon as that line of code is executed, which is whenever the file is included and as many times as the file has been included.

It is not different than any other function call.

Link to comment
Share on other sites

OK thanks. So the file which includes it does so, as I say, at the beginning, and it contains an html form. Once the user has completed the form and pressed "Submit", the data gets sent to the server. I then want register.inc.php to be run using that data. So it seems that the include statement is placed in a completely inappropriate place in the file. register.inc.php should only be included after the form has been submitted. Otherwise the data won't be there. Should it be included in the form's onsubmit property perhaps?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...