Post and get at the same time in php

前端 未结 6 2483
南方客
南方客 2020-11-27 05:56

Do you have any suggestions with my problem. I need to use get and post at the same time. Get because I need to output what the user has typed. And post because I need to ac

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 06:21

    I haven't tested this but it's a possible solution for sending GET variables through a form's action value...

    $request_uri = $_SERVER['REQUEST_URI'];
    $request_uri = str_replace("&", "?", $request_uri);
    $request_args = explode("?", $request_uri);
    foreach($request_args as $key => $val) {
        if(strpos($val, "=") > 0) {
            $nvp_temp = explode("=", $val);
            $_GET[$nvp_temp[0]] = $nvp_temp[1];
        }
    }
    

    It's not completely fool proof, but I ran across an issue with a header("Location:") bug earlier that included get variables not being seen by the server under $_GET with a url such as http://website.com/page?msg=0 but they existed in the $_SERVER['REQUEST_URI'] variable. Hope this helps and good luck!

提交回复
热议问题