Forum Moderators: coopster
############################################
<html>
<head>
<?php
function button_phpinfo() {
phpinfo(INFO_GENERAL);
}
?>
</head><body>
<form name="form1" action="button_php.php" method = "post">
<input name="trial" type="button" value="PHPinfo" onsubmit = "<?button_phpinfo()?>">
</form>
</body></html>
and well it should. It is actually done prior to the browser loading the page.
PHP code is executed on the server before the page is even delivered to the browser. Therefore you can't use a server side language to do anything with out making another request to the server.
So, to not have to make another request to the server, you have to use a client side language that is executed on the client side by the browser. Which is javascript.
What is the behaviour you are trying to build? You will just have to resub the page and have it serve something different.
You want to sub the form and have it show php_info?
you should just do a regular 'submit' on the form and handle your script with another page that does whatever you need it to do.
<slow> looks like I was not fast enough </slow>
Javascript, to the extent I understand a little of it now, is "beautiful", but I was trying to avoid it in this instance since I would have to pass a value/quantity back to a PHP variable eventually in my main script. I am striking our there as well.
Basically, I wish to submit two values (using different onclick buttons) to a function using a simple "onclick" approach, and have the function pass the value to the PHP variable. Depending on the value this receiving PHP variable receives, my script will, or will not, output error messages to a person filling out a guestbook I am constructing (or to be honest, modifying). Sounds simple if I could get a JS variable to talk to a PHP variable. I am trying out a suggestion from another forum member based on an invisible image approach to go from from JS to PHP, but I thought I could take the easy way out and confine myself to PHP all the way.