Page 1 of 1

Check user function syntax

Posted: Thu May 20, 2010 5:41 pm
by superblood
Hallo, i'm Italian and my english is very poor ... i hope you can understand me.
I have some functions built by another programmer, these functions can be called from an admin panel in a textbox (used by secretaries .. nice secretaries) who can fail the parameters or the name of the function.
I want to control if the function written by the user is right and can be saved in the database.
Can anyone help me? I've tried to catch the errors from the eval way, but i discovered that is impossible! ;-(
Thanks at all

Marco

Re: Check user function syntax

Posted: Thu May 20, 2010 5:49 pm
by JakeJ
Post some code and we'll see what we can do.

Re: Check user function syntax

Posted: Thu May 20, 2010 6:06 pm
by superblood
Stupid example, only for understand

This is the functions of the other programmer

Code: Select all

function example ($par1,$par2){
 echo "$par1 <---->$par2";
}
function example2 ($rap1,$rap2){
 $par = $par1 + $par2;
 echo "$par <---";
}
Here is the form who use the users

Code: Select all

<form name="formexample" method="POST" action="goform.php">
 <input type="text" name="function" value="">
<input type="submit" value="Save Changes">
</form>
When user press "Save Changes" i want to control in "goform.php" the syntax of the mess written in the textbox "function" before save it in the database.
For example .. if the user insert in the textbox "function" a value like this "example2 (1)" or "esample2 (1,2)" i want to alert him of his mistake before save.
I hope you can understand me...

Re: Check user function syntax

Posted: Thu May 20, 2010 8:19 pm
by JakeJ
Oh, I see. You're talking about data validation.

The best thing you can do is to go look up some tutorials on data validation in PHP, I'm sure you can find some in Italian.