English 中文(简体)
PHP会议将保留案文,但不是固定的变值
原标题:PHP session will retain text but not a posted variable value

下面的法典涉及对“Facebook”用户进行认证,其文字由“Sphp”形式活动启动。 我正在以超文本形式张贴一个示意图,其代码如下:

<html>
<body>
<form name="form" enctype="multipart/form-data" action="test.php" method="post">
    <input name="message" type="text" value=""><br/><br/>
    <input type="submit" value="Upload"/><br/>
</form>
</body>
</html>

测试守则。 网址是:

<?php session_start(); ?>
<html>
   <head xmlns:worldcentric="https://apps.facebook.com/testapp/ns#">
     <title>Test App</title>
   </head>
   <body>
   <?php
    $app_id = "191622610935428";
    $my_url = "http://www.thepropagator.com/facebook/testapp/test1.php";
    $string1 = (string)$_POST["message"];
    $_SESSION[ str ] = $string1;
   // $string2 = "teststring";
   // $_SESSION[ str ] = $string2;

  $code = $_REQUEST["code"];
  if(empty($code)) {
    $dialog_url = "https://www.facebook.com/dialog/oauth?client_id="
    . $app_id . "&redirect_uri=" . urlencode($my_url) . "&scope=email,publish_actions";
    echo("<script>top.location.href= " . $dialog_url . " </script>");
  }

$string3 = $_SESSION[ str ];
echo $string3;
   ?>
   </body>
 </html>

以上信息,Im试图储存

$_SESSION[ str ]

不能保留。 然而,当我更换线路时

    $string1 = (string)$_POST["message"];
    $_SESSION[ str ] = $string1;

With the commented out lines:

    $string2 = "teststring";
    $_SESSION[ str ] = $string2;

“试验”案文已经通过。 由于你可以看到,我试图将_POST[“message”]美元投到地狱中,但不管怎样做。 任何想法?

最佳回答

该行:

echo("<script>top.location.href= " . $dialog_url . " </script>");

造成这本画面再次从头上执行。 这里有两个问题,那就是,我把我的信息储存在一个固定变量中,在文字开始使用时,这种变数正在消失。 其他问题莫过于文字的开始和读写:

$string1 = (string)$_POST["message"];

当时并没有站出来,因此正在消除变量。 我将以上行文改为:

if (empty($_SESSION[ string ]) ) $_SESSION[ string ]=$_POST["message"];

if (empty($_SESSION[ string ]) ) $_SESSION[ string ]=$_POST["message"];

问题回答

You shouldn t need to cast as string, as by default PHP will treat it as a string.

我想到的唯一事情是,你是否相信_$_POST[information]? 努力确保其不会空洞。

Try something like this:

$_SESSION[ str ] = (empty($_POST[ message ])) ? "empty" : $_POST[ message ];

另外,在您的超文本中,

<input name="message" type="text" value="">

您没有结束投入。





相关问题
why the session in iis automatically log out?

I used iis6, and when i called a function Directory.delete(), the all the session relate this website will be logged out. and i debugged the website, i found no exception. any one have ideas on this ? ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Can I get the size of a Session object in bytes in c#?

Is it possible to get the size(in bytes) of a Session object after storing something such as a datatable inside it? I want to get the size of a particular Session object, such as Session["table1"], ...

提供严格分类的出席会议物体

提供严格分类的与会机会的最佳方式是什么? 我正计划转而选择矩阵,这正在促使汇编者抱怨我的幻觉方案拟订方法......

PHP Session is not destroying after user logout

I m trying to create an authentication mechanism for my PHP Application and I m having difficulty destroying the session. I ve tried unsetting the authentication token which was previously set within ...

热门标签