Call code from URL

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
mofle
Forum Newbie
Posts: 6
Joined: Fri Apr 06, 2007 10:02 pm

Call code from URL

Post by mofle »

I have this code:

Code: Select all

 
//Forces a recheck of every torrent
//Way number two (faster)
$utorrent = new uTorrent();
$torrents = array();
//collects an array containing every hash
foreach($utorrent->getTorrents() as $torrent) {
    $torrents[] = $torrent[UTORRENT_TORRENT_HASH];
}
//rechecks every torrent
$utorrent->recheck($torrents);
 
How can i make it run when i click on a link?


<a href=" ??? ">Link</a>


Thanks for your help ;)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Call code from URL

Post by Chris Corbyn »

Put the code in a PHP file and link to it?
mofle
Forum Newbie
Posts: 6
Joined: Fri Apr 06, 2007 10:02 pm

Re: Call code from URL

Post by mofle »

I was thinking more like this or something:


<a href="?action=recheckall">Recheck all</a>

Code: Select all

 
if ($_GET["action"]=="recheckall")
 
 
//Forces a recheck of every torrent
//Way number two (faster)
$utorrent = new uTorrent();
$torrents = array();
//collects an array containing every hash
foreach($utorrent->getTorrents() as $torrent) {
    $torrents[] = $torrent[UTORRENT_TORRENT_HASH];
}
//rechecks every torrent
$utorrent->recheck($torrents);
 
Post Reply