Check user function syntax

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
superblood
Forum Newbie
Posts: 2
Joined: Thu May 20, 2010 5:26 pm

Check user function syntax

Post 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
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Check user function syntax

Post by JakeJ »

Post some code and we'll see what we can do.
superblood
Forum Newbie
Posts: 2
Joined: Thu May 20, 2010 5:26 pm

Re: Check user function syntax

Post 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...
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Check user function syntax

Post 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.
Post Reply