Arbu Posted April 30, 2021 Share Posted April 30, 2021 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 More sharing options...
Ingolme Posted April 30, 2021 Share Posted April 30, 2021 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 More sharing options...
Arbu Posted April 30, 2021 Author Share Posted April 30, 2021 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 More sharing options...
Arbu Posted May 5, 2021 Author Share Posted May 5, 2021 The instructions I was using to do this are now in "quality review" (https://www.wikihow.com/Create-a-Secure-Login-Script-in-PHP-and-MySQL) so I guess I'll have to start again with another set of instructions. It seems incredibly complicated for something that many websites seem to do without any problems. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now