In php file I write ;
echo "<meta http-equiv=Refresh content=0;url=login.html>";

Here i load a login.html file. Along this i want to pass a php variable(suppose $nflag) content to login.html file, so that i can use it in javascript within login.html file. Please Help me.

8 Years
Discussion Span
Last Post by cwarn23

The best way to pass short variables such as a page title is using url variables so use the following code:

First page before redirect.

// Note it redirects to a php page.
echo "<meta http-equiv=Refresh content=0;url=login.php?nflag=".$nflag.">";

Login.php page

The variable passed on is <? echo $nflag; ?>.

In my example of login.php, the variable was stored in $nflag with the use of the first 3 lines making it $nflag. Also the code $_GET retrieves the variable named nflag from the url bar.

Just in case if you are confused or are wondering on how the example I wrote for login.php works I shall explain each line. As most php programmers would know, lines 1 and 3 are the opening and closing of the php code. In line 2, the variable $nflag is being assigned to be just like the previous page so you wouldn't need to use an array to call the value and for good looks. Also below will work just the same:

The variable passed on is <? echo $_GET['nflag']; ?>.

So the line in the middle of the example above is basically telling the server to 'get' the variable 'nflag' from the url bar and to echo/display it.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.