Use javascript varibles with PHP (This is an emergency)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aetoc
Forum Commoner
Posts: 37
Joined: Tue Jan 31, 2006 2:48 am

Use javascript varibles with PHP (This is an emergency)

Post by aetoc »

I have to user a varible from javascript with PHP.

Can any one help me?
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

i thought im not that specific but you are more not too specific pal...

you said
aetoc wrote:What do you want to do?

Give me some help so I can celp you.
hey, want someone to help you? wait patiently...i don't need your help if you are asking for exchange. :wink:
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

It's been asked lots. Searching this forum (and Google) would have revealed that there are two ways to do it.

AJAX is the new preferred method.
Using window.location along with $_GET is the old-style way to do it.

Code: Select all

var x = 42;
window.location='some_php_script.php?x='+x;
some_php_script.php

Code: Select all

<?php echo $_GET['x']; ?>
aetoc
Forum Commoner
Posts: 37
Joined: Tue Jan 31, 2006 2:48 am

Post by aetoc »

sorry but I'm little confuse.

I want to save the window.source in a var from the page a and send it to page b.

can this help you.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

aetoc wrote:sorry but I'm little confuse.

I want to save the window.source in a var from the page a and send it to page b.

can this help you.
It's probably too long a string for a URL, in which case you definitely need AJAX but anyway:

Code: Select all

window.location = 'some_script.php?source=' + window.source;
If you want to use AJAX but don't wish to learn much about how it works try something like XAJAX

http://xajax.sourceforge.net/
Post Reply