Connecting Tech Pros Worldwide Help | Site Map

c alling a function with a button click

chris
Guest
 
Posts: n/a
#1: Jul 17 '05
hi all

im relativly new to PHP but loving it - its fantastic isnt it (reminds me a
lot of BASIC on steroids)

my question is this

how do i call a function from a button using php??

Thanks






Savut
Guest
 
Posts: n/a
#2: Jul 17 '05

re: c alling a function with a button click


You can't do that with PHP, this is not a kind of stuff that PHP because it is server side. You need to use Javascript for that.

Savut

"chris" <someone@here.com> a écrit dans le message de news:3fd887a3$1@funnel.arach.net.au...[color=blue]
> hi all
>
> im relativly new to PHP but loving it - its fantastic isnt it (reminds me a
> lot of BASIC on steroids)
>
> my question is this
>
> how do i call a function from a button using php??
>
> Thanks
>
>
>
>
>
>[/color]


Robert Downes
Guest
 
Posts: n/a
#3: Jul 17 '05

re: c alling a function with a button click


chris wrote:[color=blue]
> im relativly new to PHP but loving it - its fantastic isnt it (reminds me a
> lot of BASIC on steroids)
>
> my question is this
>
> how do i call a function from a button using php??[/color]

You could call a PHP script using

<form action='phpscript.php' method='post'>
<input type='hidden' name='varname' value='something' />
<input type='text' name='uservarname' />
<input type='submit' value='click me' />
</form>

and then, in phpscript.php you can get the value of the hidden field by
referring to $_POST['varname'], and you can see the value that the user
typed into the text field by refferring to $_POST['uservarname'].

E.g.

echo "<p>Hello there. You typed ".$_POST['uservarname']."</p>";

That will cause things to happen when a user presses a form submission
button on a PHP script, and you can add the value of the POST variables
to a database, or vary the output of the script using if statements
based on the variables.

However, Savut is right. You may be thinking of instant response without
loading another PHP page. That is client-side scripting, using, most
often, the hideous JavaScript. JavaScript is utterly foul. Avoid it at
all costs. If you must have pretty, irritating, 'interactive' bits and
pieces on your site, think about using Flash. It costs money (boo!) but
at least it is a fixed standard (due to monopoly, albeit) and it works.
JavaScript makes even the most expensive corporate pages fail and look
poorly produced.
--
Bob
London, UK
echo Mail fefsensmrrjyaheeoceoq\! | tr "jefroq\!" "@obe.uk"
Closed Thread