I see your recordset uses $_SESSION['UserID'] and your insert uses $_POST["userid"]
That may be the issue.
Also you are validating the value of:
$totalRows_duplicatecheck
but with MySQLi the syntax should be:
$duplicatecheck->TotalRows
I think everything else looks correct.