Home > Backend Development > PHP Tutorial > The whole process of developing APP interface with PHP (2)

The whole process of developing APP interface with PHP (2)

angryTom
Release: 2023-04-07 15:06:01
forward
2848 people have browsed it

Follow the previous step of development. In practice, there will be certain problems:

The main problem is reflected in: the background needs to be logged in before it is allowed to access the subsequent controller

Here, I provide two solutions : Not much to say, let’s look at the code:

one:::::

public function loginAction($req)
    {
        if(strstr($_SERVER["QUERY_STRING"],"z") == "zhw-categorys"){
            $show_id =$_POST['id'];
            $show_name= $_POST['name'];
            if($show_id){
                $arr = array(
                    'id' => 1,
                    'name' => '测试',
                    'type' =>array(4,5,6),
                    'test' =>array(1,45,67=>array(1,2,3)),
                );
            }else{
                $arr = array(
                    'id' => 1,
                    'name' => 'jiang',
                );
            }
             wei()->zhwCategory()->show(200,'成功咯',$arr,'json');
        }
        return get_defined_vars();
    }
Copy after login

A brief explanation:

The above method is When entering the entrance of the platform, I judge: Because according to my current project, when I directly call the interface path, the path looks like this:

http://su1010.cn/admin/login?message=&next=http%3A%2F%2Fsu1010.cn%2Fadmin%2Fzhw-categorys
Copy after login

So I take the interception method. If the APP personnel directly To access my interface, then I will make a judgment. If you call the interface in a non-logged-in state, I will get the controller and directly make a judgment in the step before the return page to obtain the data for query, interpretation, and return—-> I have to say, this method is very low, but this is the method I thought of at the beginning!

two:::::::

![这里写图片描述](https://img-blog.csdn.net/20171027100824856?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvd2VpeGluXzM4MzAwOTY5/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
Copy after login

See the frame part of my painting, this part comes with the frame. . . wei framework. I'm still figuring it out now, please explain what it means specifically:

If you access my controller directly (provided that this controller is only known to you and the developer of the APP), then perform a series of operations here Operation: If you access this controller directly, then I will give you direct access to the background: for visitors, just set your user_id to 0.

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of The whole process of developing APP interface with PHP (2). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template