Page 1 of 1
Making link to function
Posted: Tue Jul 29, 2008 1:09 am
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>
Re: Making link to function
Posted: Tue Jul 29, 2008 1:18 am
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
Re: Making link to function
Posted: Tue Jul 29, 2008 1:39 am
by Volt2
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...
Re: Making link to function
Posted: Tue Jul 29, 2008 1:47 am
by WebbieDave
And what is this predeclared function supposed to do?
Re: Making link to function
Posted: Tue Jul 29, 2008 1:59 am
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>
Re: Making link to function
Posted: Tue Jul 29, 2008 2:06 am
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.
Re: Making link to function
Posted: Tue Jul 29, 2008 3:08 am
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.
Re: Making link to function
Posted: Tue Jul 29, 2008 3:42 am
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.
Re: Making link to function
Posted: Tue Jul 29, 2008 4:01 am
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.
Re: Making link to function
Posted: Wed Jul 30, 2008 9:38 am
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.
Re: Making link to function
Posted: Wed May 13, 2009 6:43 am
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