Re: Php coding help - Newbie question

From: Date: Wed, 17 Jan 2007 15:18:04 +0000
Subject: Re: Php coding help - Newbie question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-247224@lists.php.net to get a copy of this message
Ramdas wrote:
Hi Group, A very newbie question. Might be discussed earlier, please forgive. I am having a site in PHP ( not very great design ) which I need to convert/modify to use functions. Such the code for connecting / binding to Ldap is not repeated & scripts are more readable. The site deals with modifying / adding / deleting entries in a LDAP dir. In each of the pages following is done: <?php require 'validate.php' ;// validate.php checks if the user is loged in $connect = ldap_connect(ldapserver); if ($connect) { Change the previous lines to this and then move it to the bottom of the file called validate.php
Since you include that on each page, it will then be executed and upon failure, stop the script and display a connection error if ( $connect = ldap_connect(ldapserver) === FALSE ) { //display error message and die(); die("Internal problem, please try back later."); }
bind ... do the things.... }else { echo erro..} ?> Also please advice what is a correct method of checking the user's session. Currenlty I use a "HTTP_SESSION_VARS" variable to store the user's login & passwd . Each time the user hits the page these vars are checked with the existing values in the LDAP (this is done by validate.php). I would be using the Super Globals for this: $_SESSION, and don't store the password, just the username and something the say that he/she has already authenticated and is valid.
Jim Lucas
Please suggest me some good starting point where I can start a fresh with more compact/cleaner Code. Many thanx in advance. Regards Ram


« previous php.general (#247224) next »