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.

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

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

Thank u.
Where the variable
nflag
is stored?

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:

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.