Incoming call

Hi all,

I would like to set this configuration in asterisk.
I have a list of caller in a database.
When I receive a call from a caller, I would like to check in my database if this caller in inside. If this caller is in my database the call is sent to me otherwise it is sent to someone else.

My question is, is it possible with CGI scripts ?
Can somebody give me example please ?

Thanks in advance

You can use an AGI (php-agi) to connect to your DB and then send the call to you or other extension.
Check info and examples in