HomeThursday, June 30, 2016, 15:51:10

PHP Form Validation

Tuesday, February 10, 15, 13:18:12, 1 Year Ago Via wain, Hits: 541
PHP form validation :: PHP tutorial, requirement(s): PHP Server
Download source code:

$mail = $_POST['mail'];
$subject = $_POST['subject'];
$msg = $_POST['msg'];
$headers = 'From: System <noreply@example.com>';
foreach ($name as $name)
if (ereg("^\<",$name)) {
echo "<center>Invalid Characters:
<a href=\"javascript:history.go(-1)\">Go Back</a></center>";
if (ereg("^\[",$name)) {
echo "<center>Invalid Characters:
<a href=\"javascript:history.go(-1)\">Go Back</a></center>";
if (ereg("^\$",$name)) {
echo "<center>Invalid Characters:
<a href=\"javascript:history.go(-1)\">Go Back</a></center>";
if (strlen($name) < 3) {
echo "<center>Field must be at least 3 characters long:
<a href=\"javascript:history.go(-1)\">Go Back</a></center>";
if (strlen($name) > 120) {
echo "<center>Max Characters in Field: 120
<a href=\"javascript:history.go(-1)\">Go Back</a></center>";
mail($mail, $subject, $msg,$headers);
echo "O.K.";
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script language="JavaScript">
function validationEmail(maForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(maForm.mail.value)){
return (true)
alert("Invalid E-mail Address! Please re-enter.")
return (false)
<form name="maForm" action="<?php echo $_SERVER['PHP_SELF']; ?>"
method="POST" onSubmit="return validationEmail(this)">
<input type=text name="mail" value="e-Mail"><br>
<input type=text name="subject" value="e-Mail subject"><br>
<input type=text name="msg" value="e-Mail message"><br>
<input type="submit" name="submit" value="submit">

Sign In

Web Hosting
First Month Free with Coupon Code phpmonth
Unlimited Domains - Unlimited Storage
Unlimited Transfer - Unlimited Email

Upload Image with PHP [Example2]

[Example2] Tutorial - How to upload and resize image with PHP

PHP Redirect

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

PHP Mail

Sends an email.

Captcha V1 - Free PHP Script

An anti-spam form protection image written in PHP, Version: 1.1.

Advanced Contact Form - PHP Script

Advanced Contact Form with email and form field validation. Features: HTML Output(Response), Captcha Image.

How to set up password for phpMyAdmin in Wamp Server

Password for phpMyAdmin in Wamp

PHP getdate

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

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.

Contact Us PHP Form 1.1.

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

Show / Hide Div with CSS

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


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