HomeSaturday, August 18, 2018, 20:19:04
2

Preg_Match - PHP Form Validation

Tuesday, February 10, 15, 01:10:37, 4 Yaers Ago Via wain, Hits: 6532
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

How to check checkbox checked

Checking if checkbox is checked with jQuery

Password Protect With PHP

Password protect tith PHP - tutorial

Comments 1.1. :: PHP Script

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

PHP Cookies and Sessions Tutorial

PHP Cookies and Sessions Tutorials

Block Visitors From Specific IP Address

Learn How To Restrict Users From Different IP Addresses.

PHP Jquery Form

PHP Jquery Form allow your visitors to contact you directly from your website.

PHP DateTimeZone

PHP representation of time zone

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.

How to set up password for phpMyAdmin in Wamp Server

Password for phpMyAdmin in Wamp

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.
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.