I want that while there is any name equal to that it wont insert any more data.
Why are you randomizing arrays of first and last names your code will return two mixed up names but as written just one first and just one last name, so I guess from your code as is it is hard to tell what you are attempting to do. In your home table does the name column contain a first and last name because as written your coude would insert a random first and last name like Jonh Guy or Jonh Luck, it doesn't make sense to insert random names into a table.
$query = "INSERT INTO home(names)
values('$name')";
Your logic seems flawed by looking at all the code you have posted I suppose that is what you would want to test but with the code so far I am not really sure?
This will print out an error if the name exists:
if (mysql_num_rows(mysql_query("SELECT name FROM home WHERE first = '$name'"))) {
trigger_error ("<li>Your username already exists please try a different one.</li>n");