Join us at IRC!
Capitalism is an Island of wealth in a sea of poverty
Thursday, May 24, 2012
Navigation
Members Online
Total Online: 32
Web Spiders: 15
Guests Online: 32
Members Online: 0

Registered Members: 70188
Newest Member: nuk3d
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Help with php

Froger
Member

Posts: 76
Location:
Joined: 21.09.08
Rank:
Wiseman
Posted on 23-09-09 21:24
Ok I would like to make a url with php. Lets say...

http://mydomain.com/servlet/Index.php?nid=2


How would I make it to where the "nid=#" be a new number everytime the user refreshed the page.

I was thinking something like

<?php
for ($i=0;$i<=10;++$i) {
echo '<a href="http://mydomain.com/servlet/Index.php?nid='. $i . '">Click Here to refresh</a>';
}
?>

But its not working apparently. Im a noob. Sorry.

Edited by Froger on 23-09-09 21:27
Author

RE: Help with php

ynori7
Future Emperor of Earth



Posts: 1481
Location: #valhalla
Joined: 08.10.07
Rank:
Diabolical
Posted on 23-09-09 21:43
Froger wrote:
<?php
for ($i=0;$i<=10;++$i) {
echo '<a href="http://mydomain.com/servlet/Index.php?nid='. $i . '">Click Here to refresh</a>';
}
?>

That'll just print out 10 hyperlinks.

You could just say:
$i=rand(0, 10);
echo "<a href='http://mydomain.com/servlet/Index.php?nid=$i'>Click Here to refresh</a>";

But of course the user will have to click your link to make the number change, if they hit refresh it wont do it. Why exactly do you want the value in the url to change?




ynori7 http://halls-of-valhalla.org
Author

RE: Help with php

COM
Banned



Posts: 800
Location:
Joined: 31.08.07
Rank:
God
Posted on 23-09-09 21:44
I see you've got the whole concept of how php works and is utilized wrong. It's not one transnet program that ends and waits for a user reaction everytime an echo statement is used. It's one scblockedript that is executed in its entirety, in this case on the server and can then execute again if called for again, etc.
What you'd need is a session for the person where you can keep a counter variable that gets incremented every time the person asks for that page.
For more info: http://www.tizag.com/phpT/phpsessions.php
However, I'd really recommend you to get a more firm grasp on php first.


K'aem'nhi kh'rn, K'aem'nhi kh'r, K'aem'nhi kh'rmnu.
I'a Y'gs-Othoth!
Author

RE: Help with php

Froger
Member

Posts: 76
Location:
Joined: 21.09.08
Rank:
Wiseman
Posted on 23-09-09 22:17
ynori7 wrote:

$i=rand(0, 10);



This is actually what I did. The reason why is because I couldnt prevent my mobile browser from caching images no matter what I did. So I had to make sure that when Refreshing the url would change. Now my browser isnt caching images files so the page can now be reloaded successfully. Thanks yall.
Author

RE: Help with php

ynori7
Future Emperor of Earth



Posts: 1481
Location: #valhalla
Joined: 08.10.07
Rank:
Diabolical
Posted on 24-09-09 00:48
Froger wrote:
Thanks yall.

...Not entirely sure I understand, but glad I could help.




ynori7 http://halls-of-valhalla.org
Author

RE: Help with php

root_op
Lord Abortion



Posts: 467
Location: Sweden, Lidkφping
Joined: 21.03.07
Rank:
God
Posted on 25-09-09 00:52
ynori7 wrote:
Froger wrote:
Thanks yall.

...Not entirely sure I understand, but glad I could help.


Say you're working on a design but you're web browser keeps caching the CSS file, a simple solution on this is:

echo "<link src=\"/styles/theme.css?rand=".rand(0,1000)."\" />";

The CSS file doesn't parse the GET variable, although the web browser will think that this is a new file that hasn't been cached yet. Ergo, it will fetch that file instead of the cached one.


Seriously, do you even care?
root_op.asok@hotmail.com
Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.