execute a php code after a user login
The best way to execute your custom code after a user logs in is by implementing hook_user_login in a small custom module you build yourself.  Turn that php you wrote into a function then call it.

i.e.

function module_name_user_login(&amp;$edit, $account) {
  module_name_user_function($account-&gt;uid);
}

function module_name_user_function($uid) {
$usr = user_load($uid);

$array_roles=array();
//supose i'm logging in from internet
$details = array(
    'uid' =&gt; $uid,
    'roles' =&gt; array(
        21 =&gt; 'Internet' 
        )
    );
foreach($usr-&gt;roles as $key=&gt;$value) {
  if ($key!=20 and $key!=21) {
  $details['roles'][$key]=$value;
  }
}
user_save($usr, $details);
}


More about custom modules, and modules all around can be found at The Module Developer's Guide

I would not recommend putting custom php in a trigger and action.  Keeping custom code in the database is always dangerous for people coming down the line that have to maintain your site in the future.