Making link to function

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
Volt2
Forum Newbie
Posts: 4
Joined: Tue Jul 29, 2008 1:04 am

Making link to function

Post by Volt2 »

Hi, i'm quite new to php and i have a small problem. I have link as: <a href=..> and I need to link it to predeclared function. I haven't to use another php, i need to use function. Can someone help me?

For example

Code: Select all

 
<?php
function check(){.....}
?>
 
<a href=???????> Check </a>
 
WebbieDave
Forum Contributor
Posts: 213
Joined: Sun Jul 15, 2007 7:07 am

Re: Making link to function

Post by WebbieDave »

Not sure what you mean? Have you checked out some PHP tutorials? Perhaps that may clear up some things:
http://www.google.com/search?hl=en&safe ... tnG=Search
Volt2
Forum Newbie
Posts: 4
Joined: Tue Jul 29, 2008 1:04 am

Re: Making link to function

Post by Volt2 »

WebbieDave wrote:Not sure what you mean? Have you checked out some PHP tutorials? Perhaps that may clear up some things:
http://www.google.com/search?hl=en&safe ... tnG=Search
Yes, i have. But what i mean is, that i need to somehow make a "trigger". When user clicks on the link, i need to call predeclared function. But i don't know how to do it. I don;t want to use onclick or something like that...
WebbieDave
Forum Contributor
Posts: 213
Joined: Sun Jul 15, 2007 7:07 am

Re: Making link to function

Post by WebbieDave »

And what is this predeclared function supposed to do?
Volt2
Forum Newbie
Posts: 4
Joined: Tue Jul 29, 2008 1:04 am

Re: Making link to function

Post by Volt2 »

WebbieDave wrote:And what is this predeclared function supposed to do?
it's supposedto logout user. But i don't want to redirect on other .php to log him out and then redirect back. I want to simply logout him without any redirection. Something like this, but i would like to find easiest way.

Code: Select all

 
<?php
if($_GET['action']=="logout") { logout(); }
?>
 
<a href="index.php?action=logout">logout</a>
 
WebbieDave
Forum Contributor
Posts: 213
Joined: Sun Jul 15, 2007 7:07 am

Re: Making link to function

Post by WebbieDave »

What about AJAX? This would log out the user behind the scenes without him leaving the page at all. It would require Javascript but there are many free libraries out there that handle the bulk of the coding.
User avatar
stakes
Forum Commoner
Posts: 48
Joined: Tue Jun 12, 2007 12:05 pm

Re: Making link to function

Post by stakes »

WebbieDave wrote:What about AJAX? This would log out the user behind the scenes without him leaving the page at all. It would require Javascript but there are many free libraries out there that handle the bulk of the coding.
This is another example of AJAX being used for all the wrong reasons. As a user I expect to "leave" a page when I logout, it's virtually a standardized interface design pattern. There's certainly no need for an AJAX solution here.
WebbieDave
Forum Contributor
Posts: 213
Joined: Sun Jul 15, 2007 7:07 am

Re: Making link to function

Post by WebbieDave »

stakes wrote:This is another example of AJAX being used for all the wrong reasons
You must know much more about the project details than I do, being so certain that it's the wrong solution. I'm not as certain (hence I posed it as a question). It seemed the OP was asking for a way to log out without leaving the page. Hence, the AJAX suggestion. Not our job to design his project.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Making link to function

Post by onion2k »

Volt2 wrote:
WebbieDave wrote:And what is this predeclared function supposed to do?
it's supposedto logout user. But i don't want to redirect on other .php to log him out and then redirect back. I want to simply logout him without any redirection. Something like this, but i would like to find easiest way.

Code: Select all

 
<?php
if($_GET['action']=="logout") { logout(); }
?>
 
<a href="index.php?action=logout">logout</a>
 
That is the easiest way.
Volt2
Forum Newbie
Posts: 4
Joined: Tue Jul 29, 2008 1:04 am

Re: Making link to function

Post by Volt2 »

WebbieDave wrote:
stakes wrote:This is another example of AJAX being used for all the wrong reasons
You must know much more about the project details than I do, being so certain that it's the wrong solution. I'm not as certain (hence I posed it as a question). It seemed the OP was asking for a way to log out without leaving the page. Hence, the AJAX suggestion. Not our job to design his project.
Thank you, AJAX works quite well. Thank everyone for suggestion.
selom86
Forum Newbie
Posts: 13
Joined: Tue Feb 10, 2009 7:27 am

Re: Making link to function

Post by selom86 »

hi, i'm having the same problem and the whole problem is that i do not know anything about ajax. any help will be appreciated. Thanks
Post Reply