| | |
How to return a php variable, to a html file which can be use in html file as javascr
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Sep 2008
Posts: 25
Reputation:
Solved Threads: 1
How to return a php variable, to a html file which can be use in html file as javascr
0
#1 Sep 26th, 2008
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.
Login.php page
First page before redirect.
php Syntax (Toggle Plain Text)
// Note it redirects to a php page. echo "<meta http-equiv=Refresh content=0;url=login.php?nflag=".$nflag.">";
Login.php page
html Syntax (Toggle Plain Text)
<? $nflag=$_GET['nflag']; ?> <html><body> The variable passed on is <? echo $nflag; ?>. </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
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
•
•
Join Date: Sep 2008
Posts: 25
Reputation:
Solved Threads: 1
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
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:
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.
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 Syntax (Toggle Plain Text)
<html><body> The variable passed on is <? echo $_GET['nflag']; ?>. </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
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
![]() |
Other Threads in the PHP Forum
- Previous Thread: How will i solve this stuff?
- Next Thread: Where _GET[] array is formed?
| Thread Tools | Search this Thread |
301 apache api array autosuggest beginner binary broken cakephp checkbox class cms code compression cron curl data database date display dropdownlist dynamic echo email eregi error execution file files folder foreach form forms function functions google href htaccess html httppost if...loop image include insert ip javascript joomla jquery key library limit link links login mail md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf pdfdownload php phpvotingscript problem query radio random recursion remote script search searchbox server session sessions sms sorting source space sql syntax system table tutorial update upload url validator variable video volume votedown web website youtube zend






