| | |
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.
http://syntax.cwarn23.net/
My favourite PC. - Oopy Doopy Do 2U2!
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - Oopy Doopy Do 2U2!
•
•
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.
http://syntax.cwarn23.net/
My favourite PC. - Oopy Doopy Do 2U2!
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - Oopy Doopy Do 2U2!
![]() |
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 |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail mediawiki menu mlm mod_rewrite multiple mysql number oop parse paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search server sessions sms soap source space speed sql structure subdomain syntax system table tag tutorial update upload url validation validator variable vbulletin video web white xml youtube






