How to return a php variable, to a html file which can be use in html file as javascr

Thread Solved

Join Date: Sep 2008
Posts: 25
Reputation: mohammed2raja is an unknown quantity at this point 
Solved Threads: 1
mohammed2raja mohammed2raja is offline Offline
Light Poster

How to return a php variable, to a html file which can be use in html file as javascr

 
0
  #1
Sep 26th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,470
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: How to return a php variable, to a html file which can be use in html file as javascr

 
0
  #2
Sep 26th, 2008
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.
  1. // Note it redirects to a php page.
  2. echo "<meta http-equiv=Refresh content=0;url=login.php?nflag=".$nflag.">";

Login.php page
  1. <?
  2. $nflag=$_GET['nflag'];
  3. ?>
  4. <html><body>
  5. The variable passed on is <? echo $nflag; ?>.
  6. </body></html>
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 25
Reputation: mohammed2raja is an unknown quantity at this point 
Solved Threads: 1
mohammed2raja mohammed2raja is offline Offline
Light Poster

Re: How to return a php variable, to a html file which can be use in html file as javascr

 
0
  #3
Sep 26th, 2008
Thank u.
Where the variable
nflag
is stored?
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,470
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: How to return a php variable, to a html file which can be use in html file as javascr

 
0
  #4
Sep 26th, 2008
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['nflag'] 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:
  1. <html><body>
  2. The variable passed on is <? echo $_GET['nflag']; ?>.
  3. </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.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC