real_escape_string($user); $pubkey = $db->real_escape_string($pubkey); $q = $db->query("select * from user where name='$user' and pubkey='$pubkey';"); if (!$q) error("database query failed"); if ($q->num_rows==1) { success("user $user found on server"); } elseif ($q->num_rows==0) { $q = $db->query("insert into user (name, pubkey) values ('$user', '$pubkey');"); if (!$q) error("creation of user failed"); success("user $user created on server"); } else { error("server database defect"); } } catch (Exception $e) { error("login failed"); } } login($_REQUEST['user'], $_REQUEST['pubkey']); ?>