jpmonette
jpmonette

Reputation: 936

Form with email validation with Drupal

I need to create this using Drupal, but I have no idea how to simply implement this.

  1. Form with an input to insert an email and a submit button.
  2. When the form is submit, send a validation email to make sure the email addr is valid
  3. When the user validate the email (clicking the link in his email), the email is stored in the database.

Thanks a lot for your help!

Upvotes: 1

Views: 1220

Answers (1)

Berdir
Berdir

Reputation: 6891

I guess there are better solutions, but here is a rather simple way. I assume you do know how to basically do stuff in Drupal like creating forms, storing information in the database, sending mails and so on. If not, there is a link for each...

  1. Define a table with email (varchar), key (varchar), status (int) (hook_schema)
  2. Create a form where the user can enter the email (how to create a form
  3. Store the mail in the database together with a random key (like md5($mail . uniqueid()) (db_insert for D7, db_query for D6), set status to 0
  4. Send a mail to the user with a link that contains the key like yourmodule/verify/$key (drupal_mail
  5. Register that path (yourmodule/verifiy/%) in hook_menu
  6. When the user clicks on the link, look for that key in the database and set status to 1 (db_query + db_update (D7 only))
  7. Done, all mails with status 1 are now confirmed.

And as others have mentioned, drupal core user registration is already doing this.

Upvotes: 1

Related Questions