i am new to php, and have searched hours for the answer to this.
what i need is for there to be several functions waiting on the php page, and for the user to be able to call any of those functoins. it seems like there should be a way for form buttons to call specific functions. thanks to any help!!
can a user call a function
Moderator: General Moderators
Code: Select all
if($user_properties['status'] == 'admin')
{function($user_properties['uid']);}
elseif($user_properties['status'] == 'mod')
{function2($user_properties['uid']);}
else
{function3($user_properties['uid']);}please read Sticky: Before Post Read: Frames, JavaScript, and PHP Overview
then tryThe colors are set by the syntax-highlighter when you put php code in tags here
$user_properties is just a variable.
Guess you should start at http://www.php.net/docs.php and then go on with a php-tutorial.
then try
Code: Select all
<html>
<head>
<title>function test</title>
</head>
<body>
<?php
function add($a,$b) { return $a+$b; }
function sub($a,$b) { return $a-$b; }
function mul($a,$b) { return $a*$b; }
function div($a,$b) { return $a/$b; }
if (isset($_POST['action']))
{
if(in_array($_POST['action'], array('add','sub','mul','div')))
echo call_user_func($_POST['action'], 4, 2), '<hr />';
}
?>
<table>
<tr>
<td>4</td>
<td>
<form method="post">
<input type="submit" name="action" value="add"/><br />
<input type="submit" name="action" value="sub"/><br />
<input type="submit" name="action" value="mul"/><br />
<input type="submit" name="action" value="div"/><br />
</form>
</td>
<td>2</td>
</tr>
</table>
</body>
</html>Code: Select all
...$user_properties is just a variable.
Guess you should start at http://www.php.net/docs.php and then go on with a php-tutorial.