Ad block is installed and active. Please support us by disabling it.
HomeSaturday, January 20, 2018, 16:51:37
2

Preg_Match - PHP Email Validation

Tuesday, February 10, 15, 01:07:52, 3 Yaers Ago Via wain, Hits: 3363
Validate email with preg_match in php
Download source code:
http://phpform.net/download.php?f=pregmatch_mail.zip

index.php

Code:
<?php
if(isset($_POST['submit']))
{
$emailvalue = $_POST['emailvalue'];
if (!preg_match("/([A-Z0-9_-]+\@[A-Z0-9_-]+\.[a-z.]{2,7}+)+$/i",$emailvalue)){
echo "<center><font style=\"font-family:tahoma;\">..invalid email address:
<a href=\"javascript:history.go(-1)\">Go Back</a></center>";
Die();
}
if (strlen($emailvalue) < 4) {
echo "<center><font style=\"font-family:tahoma;\">..at least 4 characters long:
<a href=\"javascript:history.go(-1)\">Go Back</a></center>";
Die();
}
if (strlen($emailvalue) > 40) {
echo "<center><font style=\"font-family:tahoma;\">..max characters: 40
<a href=\"javascript:history.go(-1)\">Go Back</a></center>";
Die();
}
echo "<center><font style=\"font-family:tahoma;\">OK.";
}else{
?>
<form method="post" action="index.php">
<table>
<tr>
<td>
Text:
</td>
<td>
<input name="emailvalue" size="60" maxlength="255">
</td>
</tr>
</table>
<table>
<tr>
<td>
<input type="submit" name="submit" value="submit">
</td>
</tr>
</table>
</form>
<?php } ?>

Sign In

Sponsor

Related

Upload Attachment - PHP Tutorial

Upload attachment with PHP example, Requirement(s): PHP server

MySQL Tutorials

MySQL tutorials, MySQL training, learn MySQL, MySQL Tutorial with practical examples.

PHP Form Action Self Submit

PHP form action self submit tutorial, requirement(s): PHP server

Adodb Recordcount Example

RecordCount returns the number of rows in the record set.

Sitemap

phpForm.net Website Sitemap

PHP Links Script 1.1.

This script allows you to manage your links using a MySQL database. It features easy install, user submission, and an admin panel to add, edit and remove categories and links. The script is easy to customize to suit your needs.

PHP/MySQL Bookmarklet - PHP Tutorial

PHP/MySQL bookmarklet, bookmark current page, PHP/MySQL tutorial.

Contact Us 2.0. :: PHP Form

Version 2.0. - A contact us form with email and form field validation. It allows your visitors to send you an email directly from your website.

Bookmark Script

Allow your users to easily bookmark your site, by clicking on a link on the page.

PHP getdate

Returns an associative array containing the date information of the timestamp, or the current local time if no timestamp is given.
About Author

wain

Date Registered: Sun, Feb 8, 15
Last Time Online: Thu, Jun 15, 17
So far has created 115 entries.
wain
This author has not yet filled in any details.