Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Don't understand this short bit of code.

    [<?PHP
    require_once("./include/membersite_config.php");

    if(isset($_POST['submitted']))
    {
    if($fgmembersite->RegisterUser())
    {
    $fgmembersite->RedirectToURL("thank-you.html");
    }
    }

    ?>]

    Can someone please explain to me what this short bit of script is saying exactly?

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,633
    Thanks
    0
    Thanked 649 Times in 639 Posts
    It includes "membersite_config.php" into the surrent page provided that it isn't already included. If it can't find it then it crashes because that file is required.

    Next it checks if a form field called "submitted" was submitted to the script and if it was then it calls the RegisterUser method of the fgmembersite object and if that returns true then it calls the RedirectToURL() method passing it "thank-you.html".

    Just exactly what those methods do would depend on how the fgmembersite object is defined - presumably it is defined in "membersite_config.php" which would be why that file is required to be included.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    RyanE (02-06-2013)

  • #3
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    felgall,

    Can you tell me if my translation of this is correct?

    <?PHP
    require_once("./include/membersite_config.php");

    if(!$fgmembersite->CheckLogin())
    {
    $fgmembersite->RedirectToURL("login.php");
    exit;
    }
    ?>

    Okay, so this requires the membersite_config.php file and if it cannot be found it crashes.
    Then if it is found calls the CheckLogin method which is probably found in the required file.
    If it is true it call the RedirectToURL method which then goes to the "login.php" page.
    Is that correct?

    If so does that mean the CheckLogin method has False alternative? For instance, let's say the CheckLogin method determines if a user is logged in. The RedirectToURL method is only called if they are NOT am I right?

    Thanks a lot for the previous answer BTW.

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,633
    Thanks
    0
    Thanked 649 Times in 639 Posts
    It looks like the purpose of the code is to redirect to the login page if they are not logged in - but I'd need to see the rest of the code to be certain that the two methods are really doing what their names and the way that code is written suggest.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •