call the function when user clicks the link

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
rajendernreddy
Forum Newbie
Posts: 1
Joined: Sat Jun 20, 2009 11:23 pm

call the function when user clicks the link

Post by rajendernreddy »

Hi All
I need help in calling a PHP function on user action(clicking a link).
I want to call a function when user clicks the link on a page instead of page load.

The function actually creates a symlink to the video file,so i don't want to create the link on initial page load and I want to create the link when user click the play link.

sample code..

function createLink()
{
//link creation


return $url;
}
html code

<a href="<? =createLink()?>" />

Please help me out.
Raj
Thanks
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: call the function when user clicks the link

Post by Eric! »

I'll leave you to figure out how to get the symlink to work, I was never able to get it to work like I wanted, so I can't help there. But this is how to structure your code. (you are very close to getting it right)

Code: Select all

<? function createLink()
{
   //generate link and just echo it when ready
   echo 'http://my.symlink.video';
}
?>
html code
 
<a href="<? createLink()?>">Click here</a>
 
Post Reply