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

Preg_Match - PHP Form Validation

Tuesday, February 10, 15, 01:10:37, 3 Yaers Ago Via wain, Hits: 3340
PHP form validation with preg_match
Download source code:
http://phpform.net/download.php?f=pregmatch.zip

index.php

Code:
<?php
if(isset($_POST['submit']))
{
$textvalue = $_POST['textvalue'];
if(preg_match('#[^A-Za-z0-9]#', $textvalue)){
echo "<center><font style=\"font-family:tahoma;\">..letters and numbers only:
<a href=\"javascript:history.go(-1)\">Go Back</a></center>";
Die();
}
if (strlen($textvalue) < 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($textvalue) > 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="textvalue" 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

PHP Fwrite : fwrite

php write to file - how to write data to a file using the php frwite function

Preventing multiple form submissions

Preventing multiple form submissions

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.

Jquery PHP Contact Form

This script allows your visitors to send you an email directly from your website.

PHP str_replace

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

Getimagesize

Getimagesize function will determine the size of any given image file and return the dimensions along with the file type and a height/width text string to be used inside a normal HTML IMG tag and the correspondant HTTP content type.

Bookmark Script

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

FeedBack Form with Captcha

It allows your visitors to send you an email directly from your website.

Comments 1.1. :: PHP Script

This script allows your visitors to add comments to any single page on your web site.

PHP Forms

FREE PHP forms
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.