Send a confirmation email after the sign up, after that put that data in the database [closed]

I’m pretty new to php.
I have a sign up form with username, email and password, when the user clicks sign up I want to send an email for confirmation, and after that send the data to the database, i want to avoid using storing the password in a session variable

I can do these things separately, but i don’t know how to use them all together