I don't understand the purpose of your 'login' table. If it is to keep a login log - just use the id from the users table and a datetime. You'll need to make 2 sql queries on registering. Using mysql_insert_id() to get the id of the newly added user to the users table.
Ditto DE. However, I'm really confused as to why you've got all those loops just for inserting/checking for registration.
Have you confused table 'users' and 'classlist' in your code or are they separate entities? Is 'login' your 'registered users' table? Could you supply info w.r.t the purpose of the tables. So far I see 3 tables:
users, classlist and login.
Your first post doesn't make it clear why you should have a separate 'login' and 'users' tables. Although, it may just be me being thick.