GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Tech Best method to validate email address on form submit? (https://gfy.com/showthread.php?t=1356753)

Publisher Bucks 08-04-2022 07:19 AM

Best method to validate email address on form submit?
 
So we have just started including a small email collection link on some of our newer eBooks, people seem to be subscribing although we're also getting a lot of empty form submissions.

(The form just submits the data - Name, Email, IP, Date/time to an SQL database right now until we start working on a mailing script).

What is the best way to verify that the email being submitted (or blank form) is a valid email? Php?HTML5? Javascript? Something else?

This is the form code we're using (in case that matters?):

Quote:

<form action="https://www.domain.com/submission.php" method="post">
<input type="text" name="name" id="name" style="width: 180px" value="Full Name" />
<input type="text" name="email" id="email" style="width: 180px" value="Email Address" />
<input type="hidden" name="date" id="date" style="width: 180px" value="<?php echo date("F j, Y, g:i a"); ?>" />
<input type="hidden" name="ip" id="ip" style="width: 180px" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" />
<input type="submit" value="Get Updates" />
</form>
Any help / advice you can offer would be appreciated :thumbsup

sarettah 08-04-2022 07:48 AM

php filter_var() function.

https://www.php.net/manual/en/function.filter-var.php

https://www.php.net/manual/en/filter...s.validate.php

https://www.w3schools.com/php/php_form_url_email.asp

.

k0nr4d 08-04-2022 07:51 AM

You could start with input type='email', and remove the date and ip ones entirely and pull this data from php directly on the submission.php page.

Publisher Bucks 08-04-2022 09:53 AM

Awesome, thank you all for the suggestions :)

Coyote 08-06-2022 01:05 AM

Quote:

Originally Posted by Publisher Bucks (Post 23029141)
What is the best way to verify that the email being submitted (or blank form) is a valid email? Php?HTML5? Javascript? Something else?

Validating an email address syntax in php can be done as described by sarettah. As k0nr4d mentioned, the HTML input will also validate the syntax. However, neither method can determine if the email address actually exists. Even using checkdnsrr will only verify if there is a mail server -- Not that the user exists.

The simplest method to validate the actual email address is to send a verification email to that user whereby they either click the embedded link or paste the verification code into a field, then you check that response against the previous database entry. Include an expiration time where you delete the database entry.

Having an expiration will allow a user to re-submit their data should they initially enter an email with a typo (the user will not receive the validation email). Should that user subsequently submit correct data it will match the database entry and they can continue with your procedure.

Hope this helps.

baodb 08-06-2022 04:28 AM

Others have already mentioned the frontend changes you should make, additionally before storing the response you can also send the email through a free service like https://www.mailcheck.ai/ via your backend script.


All times are GMT -7. The time now is 05:51 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123