goldenmaza Posted November 6, 2013 Share Posted November 6, 2013 The topic is regarding the following areas: WHMCS, validatelogin, session handling, php and classes. Hello I'm developing a PHP website for a customer and this is the first time I come in contact with WHMCS. My problem lies in that I am using a class called DatabaseHandler that does the communication with the WHMCS server, and if I use the example to connect with it I cant seem to do it. However, if I use exactly the same code but put everything inside the same PHP file, instead of using several, I can seem to get a connection. So what I need to actually connect to the database seem to wanna work. What could be the problem? Do I have to do something special when you are using several php files, one or several classes and/or several functions (to make less repetitive code)? I havent gotten a formal education in PHP, what I know I've learned by myself. I'm not using the exit statement anywhere in my PHP files, even after redirects, if that help? So the following things happen when I try to communicate with WHMCS server: Index.php starts with a session_start and then I do the include statement of the class DatabaseHandler. I create an object of the handler. I create an array to send all the information (stated below) required for accessing the server. I then call one of the public functions. The 2d array looks like this: $validateUser = array(array("action", "username", "password", "email", "password2"), array("validatelogin", "login", md5("pass"), "email", "pass")); The public function, mentioned above, comes to a line where the following function will be called (pInformation is the 2d array): $results = loadData($pInformation); loadData will now try to connect with the server and it looks like this: private function loadData($postfields) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $data = curl_exec($ch); curl_close($ch); return $data; } Of course the $url variable contains the address to the correct API file on the client's server. All of the code works if its all in the same php file. But why doesnt it wanna work if I split the code between several php files? This is an annoying nag, especially since most of my code will work. Just this part of the design that doesnt wanna work. Thank you! Best regards Richard 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.