I think that if you are using a WHERE clause to find an existing row in a table to change a value, you should be using UPDATE instead of INSERT INTO. (You also have to use the syntax "SET column=value"
Something like:
$loginid = mysql_query("UPDATE userinformation SET login_id='".$randomkey."' WHERE `username` = '".$username."'") or die(mysql_error());
Double-check this in the MySQL manual for your version of MySQL, since I am hardly an expert.