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='phpscri pt.php' method='post'>
<input type='hidden' name='varname' value='somethin g' />
<input type='text' name='uservarna me' />
<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 fefsensmrrjyahe eoceoq\! | tr "jefroq\!" "@obe.uk"