I have created simpe index(with u/n,p/w and role) which calls this form:
<?php
require_once('../nusoap/lib/nusoap.php');
if (isset($POST['submitBtn'])) {
$UsernameValue=$POST['txtusrName'];
$PasswordValue=$POST['txtPassword'];
$RoleValue=$POST['txtRole'];
// Create the client instance
$client = new nusoap_client("http://127.0.1/Homework4/login.php?WSDL");
// Check for an error
echo $client->getError() ;
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
// At this point, you know the call that follows will fail
}
// Call the SOAP method
$result = $client->call('login', array('Username' => $UsernameValue, 'Password'=>$PasswordValue, 'Role'=>$RoleValue ));
// Check for a fault
echo '<h2>Result</h2><pre>';
print_r($result);
echo '</pre>';
}
?>
Which is called login.php for check errors.Although everything in my database is ok.It dosen't make check errors and it cannot redirect to pages when user ends his registration.Here is login.php file:
<? ob_start();?>
<?php
// Pull in the NuSOAP code
require_once('../nusoap/lib/nusoap.php');
// Create the server instance
$server = new soap_server();
// Initialize WSDL support
$server->configureWSDL('loginWSDL', 'urn:loginWSDL');
// Register the method to expose
$server->register('login', // method name
array('Username' => 'xsd:string','Password' => 'xsd:string','Role' => 'xsd:string'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:loginWSDL', // namespace
'urn:loginWSDL#login', // soapaction
'rpc', // style
'encoded', // use
'SELECT username, password, role FROM users' // documentation
);
function login(){
$con = mysql_connect("localhost","root","");
if (!$con){
die("Could not connect:" . mysql_error());
}
$db_selected = mysql_select_db("wthw3",$con) or die("Database not found:" . mysql_error());
if ($UsernameValue == "" || $PasswordValue == ""){
echo "At least One field is Blank";
}
else{
$query=sprintf("SELECT username, password, role FROM users WHERE username='$UsernameValue' AND password='$PasswordValue'");
$result = mysql_query($query, $con);
$row=mysql_fetch_row($result);
$count=mysql_num_rows($result);
if ( $count==1){
if ($row[2]=="User"){
ob_start();
header('Location:Unicef.html');
ob_end_flush();
exit;}
else {
ob_start();
header('Location:Administrator.php');
ob_end_flush();
exit;
}
}
}
mysql_close($con);
return $result;
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ?
$HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
Thanx for your Patient!!