English 中文(简体)
在 php 中显示错误消息
原标题:showing error message in php
  • 时间:2012-05-23 19:35:40
  •  标签:
  • php

想要显示窗体动作导致的错误消息。例如

<form action=a.php
      input .....
</form>
<span.....>
<?php 
    $variable(Initially the value of this variable null according to the result of form value will change)
?>
</span>

对于特定条件,我想在 a.php 页面中设定一个可变的 $ 值, 并使用 header (); ();) 返回到格式页面。 但 $可变的 不改变 。 我如何从 a.php 更改可变的 $?

最佳回答

使用会议变数。

in the head of each document put session_start();

在此之后, 您指定您所定义的要跨文档访问的变量 : $_SESSION[变量];

在使用标题 () 之前定义会话变量; 然后插入类似 :

if (isset($_SESSION[ variable ])){ print $_SESSION[ variable ]; unset($_SESSION[ variable ]); }

问题回答

PHP 变量不是持久性的, 当您将浏览器重定向到另一个位置时, 您的脚本执行被终止, 您将失去所有变量及其值 。 读到 < a href=> http:// bg. php. net/ manual/ en/ book. session. php" rel=“ nofollow” > session management 在 PHP 文档中存储请求间持续数据的方式 。

问题并不十分清楚,但听起来你需要这个:

if(isset($variable) AND $variable !=   ) echo "<span>$variable</span>";




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签