This sounds like you want to insert a record, but want to check if it exists first.
If you don't care if the insert fails or not (ie, you just want to do the insert and know a value has been inserted) then you could set up a unique index on name and surname.
To do the insert you could then just use INSERT IGNORE blah . Thus if there already is that combination of name and surname the INSERT will silently fail:-
INSERT IGNORE INTO sometable(id, name, surname)
VALUES(NULL, '$name', '$surname')
If you need to know the id of the record
INSERT IGNORE INTO sometable(id, name, surname)
VALUES(NULL, '$name', '$surname')
ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id)
This will return the id of the new or existing row (as appropriate) in the normal mysql functions to return the inserted row id.