Re: how to call a function when somebody click a link?



Yes, I think so.

yangsuli@xxxxxxxxx napisal(a):
the problem is that i donnot want some script.php
i want to redirect the users back on the page they were just on,with
calling a function in advance :)
you think the flag thing is the best way to do it?

Mateusz Markowski wrote:
yangsuli@xxxxxxxxx napisal(a):
i want to creat a link
when somebody click the link
the php script calls a function,then display itself :)

i have tried
<a href=<? funtion(); echo=$_server['php_self'] ?>text</a>
but it will call the function whether i click the link


then i tried this (using forms)
<form action="<?php function(); echo "<script>"; echo
"window.location.href=$_SERVER['PHP_SELF']"; echo '</script>';?>">
<input type="submit" value="text" /></form>
but it didnot work either.
my browser said there were parse errors,T_STRING expected or
something....:(


now i am thinking using a flag,say,$functioncall,
href=$_server[request_url]&functioncall=1
then if functioncall==1,call that function
but is it right?
is there some way simple to do that?


PHP works on a server, not in your browser, so it can't just call
function when you click a link. You have to send a request to the
server which will cause your script to call this function. Your last
example is good way to do it. So you have such link:
script.php?call=helloworld

and in your file script.php such code:

if ($_GET['call'] == 'helloworld') {
echo 'Hello world!';
}

Then after clicking the link your browser sends a request, PHP decides
what to do, then server sends you a appropriate response.

.



Relevant Pages

  • Re: BASIC authentication Issues with IE - Part II - Solved but WHY?
    ... We have complete control of the Request and Response ... it is up to the browser to send the credentials. ... ASP runs internally on the server. ...
    (microsoft.public.inetserver.iis.security)
  • Re: client gets always every first time for every page a 401
    ... only the first request get 401. ... Why does my Browser in case 5 not submit the Basic Authorization String ... credentials as used in 3, because they have the same root. ... Explorer has established a connection with the server by using Basic or NTLM ...
    (microsoft.public.inetserver.iis.security)
  • Re: How to do a Pick/DataBASIC http server service?
    ... use a forwarding technique which accepts the request then redirects it ... And that request to the other server might or might not also be ... Web Services - which is one of the reasons why I wrote my articles ont ... Yes, but is there even one example of PHP with UniData and, if so, what ...
    (comp.databases.pick)
  • Re: How to write something to a html textfield and send it?
    ... > No need for controlling any particular browser. ... I'm not familiar with HTTP user ... and building the request in your program. ... The server doesn't know anything about a textfield; ...
    (comp.programming)
  • Re: +" in dateiname.html = 404
    ... Wenn dann der Server den Browser nicht versteht, ... Php ist immer noch nicht wirklich threadsave. ... Apache im preforked mode laufen damit es mit php zu keinen ...
    (de.comp.os.os2.apps)