i am trying to create a soap web service.i have 3 files a client,a server and the function. The function tries to get the login credentials from the database.The problem seem to be in the function file.When i tried to exceute the function file by removing the function statement, everything works but as soon as i put back the function statement and tries to test the function from another function,it return nothing.
here is my function file:
<?php
start();
function login($username,$password)
{
include 'includes/db.php';
$data = null;
$sqlstring = "SELECT * FROM accountdetails WHERE username='$username' AND password='$password';";
$result=mysqli_query($con,$sqlstring);
if( mysqli_num_rows($result) > 0){
while($rows = mysqli_fetch_assoc($result)){
$userid = $rows["userid"];
$firstname = $rows["firstname"];
$lastname = $rows["lastname"];
$username = $rows["username"];
$email = $rows["email"];
$data = $userid.",".$firstname.",".$lastname.",".$username.",".$email;
//make it into a csv string
}
}
return $data;
}
function start(){
$data1 = login("neem","tas");
echo $data1;///return nothing
}
?>
here is my soap server file
<?php
require 'function-soap.php';
require 'lib/nusoap.php';
$server = new nusoap_server();
$server->configureWSDL("maleehahweb","uri:maleehahweb");
$server->register(
"login",
array("username"=>"xsd:string","password"=>"xsd:string"),
array("return"=>"xsd:string"));
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA :"";
$server->service(file_get_contents("php://input"));
?>
here is my client file
<?php
require 'lib/nusoap.php';
$client = new nusoap_client("http://localhost/maleehahweb/server_soap.php?wsdl",true);
$error = $client->getError();
if($error){
echo $error;
$username = "neem88";
$password = "tas";
$userid1 = null;
$firstname1 = null;
$lastname1 = null;
$username1 = null;
$email1 = null;
$parameter = array("username"=>"$username","password"=>"$password");
$result = $client->call("login",$parameter);
var_dump($result);
/*list($userid1, $firstname1, $lastname1,$username1,$email1) = explode(',', $result)*/
/*$_SESSION["userid"] = $userid1;
$_SESSION["firstname"] = $firstname1;
$_SESSION["lastname"] = $lastname1;
$_SESSION["username"] = $username1;
$_SESSION["email"] = $email1;*/
echo $userid1;//does not output anything
if($client->fault){
print_r($price);
}
?>