By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,587 Members | 1,101 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,587 IT Pros & Developers. It's quick & easy.

c alling a function with a button click

P: n/a
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


Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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" <so*****@here.com> a écrit dans le message de news:3f********@funnel.arach.net.au...
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


Jul 17 '05 #2

P: n/a
chris wrote:
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??


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"
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.