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)
-   -   PHP Question = Keeping a Variable (https://gfy.com/showthread.php?t=393172)

mkx 11-24-2004 02:24 AM

PHP Question = Keeping a Variable
 
Quick question, I am trying to make it so that a variable is kept even when the user clicks to another page. For example:

They go to www.yahoo.com?ref=55

and then from yahoo they click news. I want it to then go to:

www.yahoo.com/news?ref55

instead of just going to

www.yahoo.com/news



Hope someone can offer a script for this or an alternative easy to use method.

xxxoutsourcing 11-24-2004 02:39 AM

PHP Code:

<?php echo  $id[0]; echo $1d[1];?>

you need something like this, the more ID's you add the more code you can carry on your ?id=123456
the above code is good for only two

mkx 11-24-2004 02:47 AM

Thanks, but I don't think this solves the problem on keeping the variable stored so I can use it on the next page. I am testing out some cookie functions now, I think that is what I needed.

SilverTab 11-24-2004 02:47 AM

Quote:

Originally posted by raulph
Quick question, I am trying to make it so that a variable is kept even when the user clicks to another page. For example:

They go to www.yahoo.com?ref=55

and then from yahoo they click news. I want it to then go to:

www.yahoo.com/news?ref55

instead of just going to

www.yahoo.com/news


Hope someone can offer a script for this or an alternative easy to use method.

well let's say you go to
www.url.com/index.php?id=1234

you can print the variable in your page by using <?=$id?>
so just print it in your link...
(let's say you want news.php to carry the variable you would use
PHP Code:

<a href="news.php?id=<?=id?>">

or you can store it in a session variable if you want to carry it around on multiple pages etc etc.....lots of ways to do it..

SilverTab 11-24-2004 02:49 AM

Quote:

Originally posted by raulph
Thanks, but I don't think this solves the problem on keeping the variable stored so I can use it on the next page. I am testing out some cookie functions now, I think that is what I needed.
in this case, what you want is a session variable...

V_RocKs 11-24-2004 02:53 AM

PHP Code:

<a href=http://www.nextlinkontthepage.com?ref=<? echo $ref; ?>>link</a>


V_RocKs 11-24-2004 02:55 AM

after you drop the cookie,
PHP Code:

<?=$_REQUEST['ref']; ?>

So php checks the cookie, post and get requests for the info.

mkx 11-24-2004 03:00 AM

PHP Code:

<a href="news.php?id=<?=id?>">

This seems like the easiest method for what I am doing. Thank you guys so much, nice to get instant php support at 5am ;) :thumbsup

mkx 11-24-2004 03:07 AM

[QUOTE]Originally posted by raulph
[B]
PHP Code:

<a href="news.php?id=<?=id?>">

Got it working but you forgot the $ in <?$id?>">

Thanks again guys!

BastarD 11-24-2004 05:29 AM

Try using smarty (smarty.php.net), they have something like $smarty -> assign;

StuartD 11-24-2004 05:32 AM

Quote:

Originally posted by raulph
PHP Code:

<a href="news.php?id=<?=id?>">

This seems like the easiest method for what I am doing. Thank you guys so much, nice to get instant php support at 5am ;) :thumbsup

asking a php question... and only needing to know how to do that..

that's like stepping into a fomula 1 car and asking how to step on the gas.


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

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