Ale*_*lex 7 php validation url redirect
http://site.com/?status=4387hg843hg89473gh87934h89g734hg8973hg9873hg8973h4987g3h489g7h89h849g5
status
PHP可以读取的最大大小是多少?
我希望在登录或注册时传递错误/成功消息,我能做到的唯一方法是重定向到URL并将消息作为参数附加到该URL.
喜欢:
<?php
$errors = array(
1 => 'Password must have between 6 and 20 characters',
2 => 'User name must contain only A-Z, a-z and 0-9 characters',
3 => 'Captcha code does not match',
);
$errors = base64_encode(serialize($errors));
header("Location: http://www.example.com/?status={$errors}");
die();
Run Code Online (Sandbox Code Playgroud)
(如果你知道不同的方法,请告诉我;)
HTTP协议不对URI的长度设置任何先验限制.服务器必须能够处理它们所服务的任何资源的URI,并且如果它们提供可以生成这种URI的基于GET的表单,它应该能够处理无限长度的URI.如果URI长于服务器可以处理的长度,服务器应该返回414(Request-URI Too Long)状态(参见10.4.15节).
话虽如此,许多浏览器不允许无限长度的URL.例如,Internet Explorer的限制为2,083个字符.
在你的情况下,我建议使用一个会话变量来存储错误,一旦显示它就删除它.
产生错误的文件:
<?php
$errors = array(
1 => 'Password must have between 6 and 20 characters',
2 => 'User name must contain only A-Z, a-z and 0-9 characters',
3 => 'Captcha code does not match',
);
session_start();
$_SESSION['errors'] = $errors;
header("Location: http://www.example.com/");
die();
Run Code Online (Sandbox Code Playgroud)
另一页:
<?php
session_start();
if ( ! empty($_SESSION['errors']) )
{
// Do something with the errors.
// Remove the errors from the session so they don't get displayed again later.
unset($_SESSION['errors']);
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5376 次 |
最近记录: |