Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-05-2013, 06:02 AM   PM User | #1
RyanE
New to the CF scene

 
Join Date: Feb 2013
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
RyanE is an unknown quantity at this point
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?
RyanE is offline   Reply With Quote
Old 02-05-2013, 08:33 AM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,528
Thanks: 0
Thanked 503 Times in 494 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
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/
felgall is offline   Reply With Quote
Users who have thanked felgall for this post:
RyanE (02-06-2013)
Old 02-07-2013, 02:18 AM   PM User | #3
RyanE
New to the CF scene

 
Join Date: Feb 2013
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
RyanE is an unknown quantity at this point
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.
RyanE is offline   Reply With Quote
Old 02-07-2013, 05:49 AM   PM User | #4
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,528
Thanks: 0
Thanked 503 Times in 494 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
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/
felgall is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:26 AM.


Advertisement
Log in to turn off these ads.