Teach me to make a user registration system

I want to make a flash+PHP (or flash+PHP+MySql) user registration system.
The features about input e-mail then generate a random number password and then send it to that email. User next time can enter email as user name, and that random number as password.

Can anyone teach me or recommend a tutorial for this?

Thanks.