How to call a php function on click of a hyperlink??
calling php function on click of a hyperlink
Collapse
This topic is closed.
X
X
-
johnTags: None -
Tim Van Wassenhove
Re: calling php function on click of a hyperlink
In article <4c900ea0.04080 70444.2d6f3a30@ posting.google. com>, john wrote:[color=blue]
> How to call a php function on click of a hyperlink??[/color]
Well, php runs at the serverside. So you have to make sure that with the
"click of a hyperlink" the script is requested(activ ated).
<a href="activate. php?url=foo">ht tp://foo</a>
would result in a resuest of activate.php. So in activate.php you can do
whatever you want, and redirect with header('Locatio n: '.$_GET['url']);
--
Tim Van Wassenhove <http://home.mysth.be/~timvw>
-
Doug B
Re: calling php function on click of a hyperlink
"Tim Van Wassenhove" <euki@pi.be> wrote in message
news:2nk1gtF1kv 64U1@uni-berlin.de...[color=blue]
> In article <4c900ea0.04080 70444.2d6f3a30@ posting.google. com>, john wrote:[color=green]
> > How to call a php function on click of a hyperlink??[/color]
>
> Well, php runs at the serverside. So you have to make sure that with the
> "click of a hyperlink" the script is requested(activ ated).
>
> <a href="activate. php?url=foo">ht tp://foo</a>
>
> would result in a resuest of activate.php. So in activate.php you can do
> whatever you want, and redirect with header('Locatio n: '.$_GET['url']);
>
>
> --
> Tim Van Wassenhove <http://home.mysth.be/~timvw>[/color]
To clarify....
URL's in the hyperlinks do not reference parts of a php script, such as a
function, or even a line of code. The script they reference will run in its
entirety, So if your link points to http://your.server.com/script.php?x=yes
all of script.php will run. Once the script is running, you will have to
have conditional sections in your script that are called into action by the
x=yes portion.
The usual ways to control sections executed would include the "if" or
"switch/case" controls. Using if is pretty straightforward . If the
condition is met, do this, if not, do something else. switch is also handy,
and can be good when you have a long string of possiblilities. Like if you
find yourself needing a constuct like... if they like blue, do this, if the
like red do this other thing, if they like green do something else, if they
like purple, do something else entirely, everyone else go over here.
I usually build forms that submit their data to themselves, sometimes many
forms in a rows will be all one script. I control some of these using a
POST variable of "$step" and have conditionals looking for the step number.
If ($_POST[step] == 1) run this section; and so on for step 2 3 4 5 6 and so
on. Each step is another form submission in a multipart process such as
signing up for a web site.
I probably confused things even further...
Short answer is:
The whole script you send them to with the link will run. Inside that
script you will need to either have the entire script do one thing or you
will have to build in conditional statements and controls to guide them thru
the script.
Comment
Comment