At 11:46 AM 2/12/2006, Alain Roger wrote:
I have a link in my web page and when user click on this link, i would like
to execute a PHP function with a parameter.
how can i do it ?
If you're using PHP in the usual way as a server-side script, it
doesn't run in the same time-frame as user interaction such as
clicks. First PHP generates the page and downloads it to the client
(browser); then the human interacts with the page.
Therefore in order to trigger a PHP function from a human event, you
must request a page or submit a form to the server.
However, it sounds like what you're really after is an immediate
response to a user action, in which case you should be using a
client-side scripting language such as JavaScript.
If you really do want to execute a PHP function on the server after a
client-side interaction, you can:
1) request a page with parameters, such as:
<a href="http://example.com/smart.php?thing=thang">click here</a>
2) submit a form with fields that contain the parameter values:
<form action="smart.php" ...>
<input name="thing" value="thang" ... />
3) use "Ajax" technology (XMLHttpRequest) to bring new data into your
web page without making a complete reload request.
Paul
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php