Ad block is installed and active. Please support us by disabling it.
HomeWednesday, April 25, 2018, 08:53:11
2

Preg_Match - PHP Form Validation

Tuesday, February 10, 15, 01:10:37, 3 Yaers Ago Via wain, Hits: 5932
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 $_GET Function

Get function in PHP

Show / Hide Div with CSS

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

PHP Form Validation

PHP form validation :: PHP tutorial, requirement(s): PHP Server

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.

How to insert new line (IP Address) with fwrite

How to insert new line (IP Address) with fwrite, Get IP address and write to file.

Adodb Recordcount Example

RecordCount returns the number of rows in the record set.

PHP Redirect

Header (location) redirect must be processed before any output to the browser.

How to check checkbox checked

Checking if checkbox is checked with jQuery

E-Cards 1.1. PHP Script

This script will allow your visitors to send e-cards to their friends. It features admin notification and HTML output.To use the "e-cards" script completely free , the "powered by" link at the bottom of the pages must stay intact.

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