English 中文(简体)
网页上的硬盘储存数据
原标题:Can t store session data between pages

我在全部的营地项目中都遇到一个问题,因为i 采用OOP是,如果用户提交表格,就应当使用。

when it goes to processing it and if it has an error i save a message in the session and redirect them to the same page

这只是一个样本,当然是当它重新引导它 all住那里的所有领域时。

顺便说一句,我有一个登记表。

<?php if(!empty($message)) { echo $message } ?>
<form action ="forms/register.php">
first name: <input type="text" name="first_name" />
username:<input type="text" name="username" />
<input type="submit" value = "submit" />
</form>

这是法典的形式/登记。 php

  if(isset($_POST[ submit ])) {
    $first_name = $_POST[ first_name ];
    $username = $_POST[ username ];

 if(empty($first_name) || empty($username) {
    $session -> message("please fill in all the fields");
    redirect("../register.php");
 } else {
    // do something else like insert query
 }

 }

我的问题是,如果首先——姓名或用户——姓名是空洞的,而是转而登记。 php

它赞同错误信息,即不存在任何问题。

但是,田间是空的,第一个是名人,用户是空的。

so the user has to fill it all again

我的一位朋友建议,在届会期间或某件事情中挽救它。

因此,我想知道,如果是这样的话,那么没有人会错失,那么,这又意味着什么。

预 收

长期痛苦

最佳回答

您可以储存你想要在届会变量的页次后以形式保持的任何价值,然后在表格页上检索这些数值,并在“条码”中反映这些数值。

问题回答
session_start(); $_SESSION[ nick ] = $_GET[ nick ];

更多/更好的实例:

http://php.net/manual/en/function.session-start.php

Not sure what issue you exactly are facing (also what $session is inside your workflow?). However, i recommend using PHP inbuild session support. http://php.net/manual/en/features.sessions.php

从上述联系本身来看:

<?php
session_start();

if(isset($_SESSION[ views ]))
{
    $_SESSION[ views ]=$_SESSION[ views ]+1;
}
else
{
    $_SESSION[ views ]=1;
    echo "Views=". $_SESSION[ views ];
}
?>

排在法典之上只是保持页面观测的轨道。 页: 1





相关问题
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 ...

热门标签