GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Passing variables from PHP to Javascript and vice versa (https://gfy.com/showthread.php?t=92202)

psyko514 12-05-2002 11:31 PM

Passing variables from PHP to Javascript and vice versa
 
i have a frames page with a menubar at top and the main content below. i want the main page to redirect to a PHP page based on screen size using the following format

if (screen.width > 1024)
{window.location.href='girls1024.php?id=XXXXX'}

where XXXXX will be sent to JS from PHP

i know very little about JS, so help me out here... thanks :)

Exxxotica 12-05-2002 11:32 PM

uhh....

FATPad 12-05-2002 11:38 PM

Your main page has to set those values. They'll be part of the html document that is sent to the browser. Since it sounds like the main page will be dynamic in nature, whatever you use to build the main page should just fill that information in as part of the html document.

magnatique 12-05-2002 11:42 PM

(for this message, whenever I put "*", replace it by a "?" ... I can't write it the right way, else it treats it as php)

ok assuming your page you are linking to is called

www.domain.com/redir.php

you'd link to it like

www.domain.com/redir.php?id=magnatique

then, on that redir.php page you'd have

if (screen.width >= 1024)
{window.location.href='girls1024.php?id=<* echo $id;*>'}
else if (screen.width >= 800)
{window.location.href='girls800.php?id=<* echo $id;*>'}
else
{window.location.href='girls640.php?id=<* echo $id;*>'}

Exxxotica 12-06-2002 12:00 AM

uhh...

psyko514 12-06-2002 01:23 AM

i tried that and it didn't work... as far as i know (and correct me if i'm wrong) you can't imbed one script in another.

Quote:

Originally posted by magnatique
(for this message, whenever I put "*", replace it by a "?" ... I can't write it the right way, else it treats it as php)

ok assuming your page you are linking to is called

www.domain.com/redir.php

you'd link to it like

www.domain.com/redir.php?id=magnatique

then, on that redir.php page you'd have

if (screen.width >= 1024)
{window.location.href='girls1024.php?id=<* echo $id;*>'}
else if (screen.width >= 800)
{window.location.href='girls800.php?id=<* echo $id;*>'}
else
{window.location.href='girls640.php?id=<* echo $id;*>'}


Calvinguy 12-06-2002 07:11 AM

Quote:

Originally posted by psyko514
i tried that and it didn't work... as far as i know (and correct me if i'm wrong) you can't imbed one script in another.


Of course you can... JS is client based, PHP server based

magnatique 12-06-2002 11:42 AM

php has to be enabled on the server ;)

also, as I said, replace the * by ?


whatever you put in a url like
?id=test

you call it back ('test')
by writing
<* echo $id;*>

where the * is a ?

Rory 12-06-2002 11:48 AM

Quote:

Originally posted by magnatique
php has to be enabled on the server ;)

also, as I said, replace the * by ?


whatever you put in a url like
?id=test

you call it back ('test')
by writing
<* echo $id;*>

where the * is a ?

Register Globals = not only horrible coding habit, but now off by default in later versions of PHP (thank god).

PHP Code:

<?php
$id 
$_GET['id'];
echo 
"$id";

or on one line :

PHP Code:

<?php $id $_GET['id'];echo "$id";?>

Just trying to get rid of bad habits before they start growing on newbies. :thumbsup

Rory

Rory 12-06-2002 11:52 AM

Quote:

Originally posted by psyko514
i tried that and it didn't work... as far as i know (and correct me if i'm wrong) you can't imbed one script in another.


Jesus you are a fuckin mess man. Try and explain what you are doing a bit beter and I will try and help. What is id and where is it acquired. If its a JS variable you will need to do .......?id="+id+" (or whatever you called the javascript variable). I have no clue really though what you are trying to accomplish.

Rory

psyko514 12-06-2002 11:38 PM

Quote:

Originally posted by magnatique
php has to be enabled on the server ;)

also, as I said, replace the * by ?


whatever you put in a url like
?id=test

you call it back ('test')
by writing
<* echo $id;*>

where the * is a ?

number one, php is enabled by the server.
number two, i had originally tried it in the format you suggested, and that didn't work, so that's why i came here.
you're 100% right about java being client-side and php being server-side... i thought it would work, but it didn't

as for your comment rory, i'm a "newb" when it comes to javascript... not when it comes to php/c++

i'll attempt to explain my objective a bit better. i have a frames page, the top frame being a menu bar controlling the main frame.
the surfer will fill out a form in the main frame and id is a unique ID assigned to them when they sign up for my site. it's the primary key of a mysql table.
when the login, a script retrieves their info from the table, and ID gets plugged into a hidden form element.
when they fill out the form and submit it, the form gets processed and they're brought to the javascript redirect page which redirects them based on their screen size, giving them a unique page based on their screen size and ID

-------------------------------------------------
it's all moot because i've solved the problem
but thanks anyways :)

magnatique 12-07-2002 09:51 PM

am a php newb myself, trying to learn it hehe..

thanks for the heads up rory, will code this way from now on ;)


All times are GMT -7. The time now is 02:58 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123