HomeMonday, June 18, 2018, 15:06:53
2

Preg_Match - PHP Email Validation

Tuesday, February 10, 15, 01:07:52, 3 Yaers Ago Via wain, Hits: 6159
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

ShoutBox 1.1. PHP Script

ShoutBox allows your users to post short messages on your site. The script is lightweight and very easy to install and use.

PHP Cookies and Sessions Tutorial

PHP Cookies and Sessions Tutorials

Show / Hide Div with CSS

CSS Display and Visibility:The visibility property specifies whether or not an element is visible.

Smarty - Create dynamic Web Pages with PHP & MySQL

Creating Dynamic Web Pages Using Smarty and MySQL - Requirement(s): PHP Server, MySQL

Stack Overflow Clone Script - Ja2BU

Open source question and answer script written in PHP, MySQL and jQuery. Main features are: SEO friendly url's, private message system, rating system, comments system.

Block Visitors From Specific IP Address

Learn How To Restrict Users From Different IP Addresses.

PHP Cookies - setcookie

Defines a cookie to be sent along with the rest of the HTTP headers.

Send This Link PHP Script

A popup form which allows your visitors to send a referral link from your site. It features admin notification and HTML output.

PHP Str_replace - PHP Tutorial

This function returns a string or an array with all occurrences of search in subject replaced with the given replace value.

Upload Image With PHP

[Example3] Tutorial - How to upload image in php.
About Author

wain

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