令人困惑的POST行为 - 做两次? [英] Confusing POST behavior -- doing it twice?

查看:142
本文介绍了令人困惑的POST行为 - 做两次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(先前在comp.lang.php上发布但未收到回复。在Dreamweaver论坛中交叉发布




我对什么感到困惑继续方法POST。这是我的代码概述

,草拟出来:


<?php

if(isset($) _POST [''提交''])&& $ _POST [''提交''] =="提交"){

---做一堆东西---

if(isset($ _ SESSION [''Error'']))unset($ _ SESSION [''Error'']);

if(strcmp($ A, any){

//验证邮政编码是否为数字且是五位数

如果(!is_numeric($ _ POST($ zip))strlen($ _POST($ zip))!= 5)然后{

$ _SESSION [''错误''] ="错误说明" ;;

标头("位置:thisSite.php :);

}

}

}

header(" Location:anotherSite。 php :);

?>


......在表单说明中我有一个

< ?php if(isset(($ _ SESSION [''Error'']))echo $ _SESSION [''Error''];?>

(注意:表单类型为POST)。


所以这是问题所在:

1 - 当我开始时,没有错误消息。

2 - 我故意输入一个糟糕的邮政编码并且有一个除any之外的值

并点击提交它。

3 - 而不是回到thisSite.php并显示错误消息,

它去了to anotherSite.php。

4 - 如果我然后点击浏览器上的后退箭头,它会在thisSite.php上显示错误

消息


似乎

1 - 在提交时它通过逻辑并设置错误。

2 - 它必须经过一秒钟时间,但这次采用

默认设置为any对于控制A等绕过zip

代码的逻辑,所以转到anotherSite.php。


请在这里帮助我。


雪莉

(posted previously on comp.lang.php but no response received. Cross-posted
in the dreamweaver forum)

I am confused about what goes on with method POST. Here is an overview of a
my code, sketching it out:

<?php
if (isset($_POST[''Submit'']) && $_POST[''Submit'']=="Submit") {
---Do a bunch of stuff---
if (isset($_SESSION[''Error''])) unset($_SESSION[''Error'']);
if (strcmp($A, "any") {
// Verify that a Zip code is numeric and is five digits
If (!is_numeric($_POST($zip)) strlen($_POST($zip)) != 5) then {
$_SESSION[''Error''] = "an error description";
header("Location: thisSite.php:);
}
}
}
header("Location: anotherSite.php:);
?>

...... in the form description I have an
<?php if (isset(($_SESSION[''Error''])) echo $_SESSION[''Error'']; ?>
(Note: The form is type POST).

So here is the problem:
1 - When I start, there is no error message.
2 - I deliberately put in a bad zip code and have a value other than "any"
in the A control and click to submit it.
3 - Instead of going back to thisSite.php and displaying the error message,
it goes to anotherSite.php.
4 - If I then hit the back arrow on the browser, it displays with the error
message on thisSite.php

It seems that
1 - on the submit it goes through the logic and sets the error.
2 - It then must be going through a second time, but this time taking on the
default setting of "any" for control A and so bypass the logic on the zip
code and so goes to anotherSite.php.

Please help me here.

Shelly

推荐答案

_POST [''提交''])&&
_POST[''Submit'']) &&


_POST [''提交''] =="提交"){

---做一堆东西---

if(isset(
_POST[''Submit'']=="Submit") {
---Do a bunch of stuff---
if (isset(


_SESSION [''错误'']))取消设置(
_SESSION[''Error''])) unset(


这篇关于令人困惑的POST行为 - 做两次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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