Form validation with functions


Posted on 16th Feb 2014 07:03 pm by admin

Hi there

I am trying to make a very simple form validation function. I currently have the following

function formValidate($field, $msg) {

if (empty($_POST['$field'])) {
$errors[] = $msg;
} else {
$field = mysqli_real_escape_string($dbc, trim($_POST['$field']));
}

}// end of function

formValidate('form', 'You forgot to enter the form');


When I run the script and enter nothing into the $_POST['form'] field it still executes an empty record into the database.

What am I doing wrong?

No comments posted yet

Your Answer:

Login to answer
169 Like 33 Dislike
Previous forums Next forums
Other forums

date function help
i need help with date function

Code: [Select]<!DOCTYPE HTML PUBLIC "-//W3C//DTD H

??????? Omega Speedmaster
[b]лучше омега часы реплики[/b] [b][url=http://www.omegawatchessales.top/ru/]л

UGG Boots | Klassisk EARMUFF UGG , UGG ®
[b][url=http://www.bootsforcheap.cn/no/classic-hekle-ugg-c-4.html]salg Classic Hekle UGG [/url][/b]

Britney Spears Red Herve Leger mit V-Ausschnitt Bandage Kleid [Britney Spears Red Bandage Dress] - €167.40 : hervelegercheap, feardress.com
herve legerherve leger kleidung
herve leger kleidet






[b][url=http://www

Replica Breitling Uhren
[b][url=http://www.topcheapwatches.top/de/]Replik Schweizer Uhren aaa +[/url][/b] [b][url=http://www

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Google+ Indyaspeak @ Pinterest RSS