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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to