Connecting Tech Pros Worldwide Forums | Help | Site Map

php + javascript

Newbie
 
Join Date: Apr 2007
Posts: 3
#1: Apr 11 '07
hi
first let me say that im not a php programmer (till now all i did was asp)
i realize that php is kinda easy to understand and im giving it a shot...
so please be patience... (-:
i want to do this:
take varible from a url, in asp i could use request.querystring but i understand that its not safe to use it with php (i have to register_globals=on) so i decided to listen and not to use it.
i cant use a form.
so i thought using javascript, take the var from the url put it in a javascript function and then send it to the php function.
or maybe there is a better way to this....
can you guys give some directions or a function the does this
thank you
Yaniv

Newbie
 
Join Date: Apr 2007
Posts: 3
#2: Apr 11 '07

re: php + javascript


maybe more details...
i want this:
<a href="www.myDomain.com/index.php?id=XXX" target="_blank">TEST</a>
in the index.php, use the "id" value
ak1dnar's Avatar
Moderator
 
Join Date: Jan 2007
Location: Colombo
Posts: 1,440
#3: Apr 12 '07

re: php + javascript


Quote:

Originally Posted by yaniv

hi
first let me say that im not a php programmer (till now all i did was asp)
i realize that php is kinda easy to understand and im giving it a shot...
so please be patience... (-:
i want to do this:
take varible from a url, in asp i could use request.querystring but i understand that its not safe to use it with php (i have to register_globals=on) so i decided to listen and not to use it.
i cant use a form.
so i thought using javascript, take the var from the url put it in a javascript function and then send it to the php function.
or maybe there is a better way to this....
can you guys give some directions or a function the does this
thank you
Yaniv

Using the register_globals=on is a default feature with the modern PHP versions.How ever there are lots of ways to do what ever you need.

You can use sessions to pass the variables with your application.Give it a try by using this Tutorials.
http://www.w3schools.com/php/php_sessions.asp
http://www.tizag.com/phpT/phpsessions.php

And according to your suggestion,if you familiar with JS that also possible, with some ajax.
Read thisThread you will get a answer. here no need of ajax. try to find out it by your self.
Newbie
 
Join Date: Mar 2007
Posts: 13
#4: Apr 12 '07

re: php + javascript


if the address is this index.php?id=value

then the variable id could be use like this $_GET['id']
if you want to read all the query string (variable and their values) you can use $_SERVER['QUERY_STRING']

no need to use javascript for this even if safe mode is enable.

also if you use the method post you can use the variabla with this syntax $_POST['variable']
Newbie
 
Join Date: Apr 2007
Posts: 3
#5: Apr 12 '07

re: php + javascript


hi
first thanks for your replies!

you mean:
the url is ....index.php?id=XXX
and in the index.php i do $_GET[id] and i will get the XXX?
Reply