Table of Contents
php通过隐藏表单控件获取到前两个页面的url,表单url
问怎通过php获取提交页面的URL
PHP使用URL传递变量,可以否不用表单提交过去?
Home php教程 php手册 php通过隐藏表单控件获取到前两个页面的url,表单url

php通过隐藏表单控件获取到前两个页面的url,表单url

Jun 13, 2016 am 09:25 AM
php

php通过隐藏表单控件获取到前两个页面的url,表单url

自己在学习过程中也遇到了类似的问题:
比如,后台是想做成这样子的:

但是实际则是这样的:

解决方法:
通过隐藏表单控件

<input type="hidden" name="prevurl" value="<&#63;php echo $_SERVER['HTTP_REFERER']&#63;>">
Copy after login

这样$_SERVER['HTTP_REFERER']的值看上去就暂时存到了$_POST[prevurl]里。

其实这个方法的原理还是把上一个url通过post的方法post到了别的地方去,只不过这个的post是当前页面而已

在之后的开发中,新建文章的部分会有一个select标签,如果把select标签的disabled启用的话,将不能post所选的value值,所以我又一次使用了hidden的欺骗方法,暗地里提交一次,屡试不爽。

问怎通过php获取提交页面的URL

PHP $_SERVER['HTTP_REFERER']
使用 $_SERVER['HTTP_REFERER'] 将很容易得到链接到当前页面的前一页面的地址。
只有通过 超链接以及 POST 或 GET 表单访问的页面,$_SERVER['HTTP_REFERER'] 才有效。
 

PHP使用URL传递变量,可以否不用表单提交过去?

除了图片以外,都可以用url传递变量过去
获取方式为如 a.php?a=123
那就用$_GET['a']输出来
如果多级变量可以用 a.php?a=123&b=456&c=789
echo $_GET['a'] 123 echo $_GET['b'] 456
最好得到的变量,写个函数过滤一下,保证网页安全
其实使用了GET照样可以用post得到表单里面的值,如果没有得到,可以看一下 post和get设置是否驳开了
 

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles