通过php函数中的表单动作在url中传递参数

时间:2014-07-28 08:32:58

标签: php soap html-form-post

我正在使用Web服务成功从SOAP客户端获取参数。我想通过html表单在url中传递这些参数,以便我可以使用此参数连接到我的系统。我有2个功能。函数login()用于设置SOAP客户端和函数getVehicle()的连接参数以获取此参数。在getVehicle()中,我想从url向client.php发送参数user,hash password,dealer_number,corporate_group_id。我希望从表单操作发送此参数而不提交按钮。

的index.php

    function login()
    {
        $wsdl = 'http://www.schwackenet.de/awonline/de/service2/SNWebService.php?wsdl';
        $options = array('trace' => true);

        $params = array(
          'user' =>               utf8_encode('deshmukh'),
          'password' =>           utf8_encode('deshmukh'),
          'corporate_group_id' => '101',
          'dealer_number' =>      'INT31303',
          'dms_id' =>             'A13T2D19',
          'dms_image_url' =>      '', 
          'dms_keepalive_url' =>  '', 
          'dms_followup_url' =>   ''  
        );

        $client = new SoapClient($wsdl, $options);  
        $result = $client->Login($params);      
        return $return;
    }

if($parameter['aktion'] == 'getVehicle') 
{       
    //var_dump(Login());
    $vehicle=login();
    $user_login=$vehicle['user'];
    $password=$vehicle['password'];
    $dealer_no=$vehicle['dealer_number'];
    $group_id=$vehicle['corporate_group_id'];

//form action here         

    }

2 个答案:

答案 0 :(得分:1)

您可以使用内置的php函数client.php将数据作为GET请求传输到file_get_contents()

if ($parameter['aktion'] == 'getVehicle') 
{       
    $vehicle=login();
    $user_login=$vehicle['user'];
    $password=$vehicle['password'];
    $dealer_no=$vehicle['dealer_number'];
    $group_id=$vehicle['corporate_group_id'];

    // send the data to your system
    $system_url = 'http://yoursite.com/path/to/client.php';
    header("Location: $system_url?user=$user_login&password=$password&dealer_number=$dealer_no&corporate_group_id=$group_id");
    exit();
}

如果您愿意,可以让client.php重新输入“成功”或“错误”输出,然后您就可以在$response变量上找到它,您可以记录它或用它做其他事情

答案 1 :(得分:1)

login()你要归还$return,这是错误的。您需要返回$result,其中包含curl请求的结果。

function login()
    {
        $wsdl = 'http://www.schwackenet.de/awonline/de/service2/SNWebService.php?wsdl';
        $options = array('trace' => true);

        $params = array(
          'user' =>               utf8_encode('deshmukh'),
          'password' =>           utf8_encode('deshmukh'),
          'corporate_group_id' => '101',
          'dealer_number' =>      'INT31303',
          'dms_id' =>             'A13T2D19',
          'dms_image_url' =>      '', 
          'dms_keepalive_url' =>  '', 
          'dms_followup_url' =>   ''  
        );

        $client = new SoapClient($wsdl, $options);  
        $result = $client->Login($params);      
        return $result;
    }

if($parameter['aktion'] == 'getVehicle') 
{       
    $vehicle=login();
    var_dump($vehicle);

  }