处理完成后删除 URL 中的 GET 参数(不使用 POST),PHP [英] remove GET parameter in URL after processing is finished(not using POST), PHP

查看:22
本文介绍了处理完成后删除 URL 中的 GET 参数(不使用 POST),PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的网址 http://localhost/join/prog/ex.php

当我使用 GET 方法时,url 地址像这样 http://localhost/join/prog/ex.php?name=MEMORY+2+GB&price=20&quantity=2&code=1&搜索=添加

When i use GET method the url address like this http://localhost/join/prog/ex.php?name=MEMORY+2+GB&price=20&quantity=2&code=1&search=add

我的问题是:所以,我仍然使用 GET 方法,但我想在 GET 方法中处理完成后,我想将 url 返回(删除参数)到 http://localhost/join/prog/ex.php,和以前一样(不使用 POST 方法).我该怎么做?

My question is : so, I still use the GET method but I want to after processing in GET method is finished, I want to the url back(remove parameter) into http://localhost/join/prog/ex.php, as previously (not using POST method). How can i do it?

推荐答案

把它放在你的 HTML 文件 (HTML5) 中.

Put this in your HTML file (HTML5).

<script>    
    if(typeof window.history.pushState == 'function') {
        window.history.pushState({}, "Hide", "http://localhost/join/prog/ex.php");
    }
</script>

或者使用例如使用会话的后端解决方案;

Or using a backend solution using a session for instance;

<?php
    session_start();

    if (!empty($_GET)) {
        $_SESSION['got'] = $_GET;
        header('Location: http://localhost/join/prog/ex.php');
        die;
    } else{
        if (!empty($_SESSION['got'])) {
            $_GET = $_SESSION['got'];
            unset($_SESSION['got']);
        }

        //use the $_GET vars here..
    }

这篇关于处理完成后删除 URL 中的 GET 参数(不使用 POST),PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆