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

Any help with my email script?
I have an email script, I have not tested it, although someone tested it for me and said it worked f

How to get all server headers like Live http Headers does
Hey all, like many of you I use the Firefox addon "Live http Headers". I'm trying to write

SMTP server...
I recently found a tutorial online on SMTP authentification for sending emails from webpages, here i

Remove letter from numeric textbox
I have a textbox that will search the employee database by entering in the employee ID and it will r

file downloaded can't be read !!
<?php
$fileName = 'mypic.jpg';
$mimeType = 'image/jpeg';
header('content-dispositio

mod_rewrite.c on windows ??
why it's not working on windows while it's working on other hosts???

this is the code i got

Inserting a variable in a link
I have this code that I want to insert for my own variable but I have no idea how. This is what I wa

first few characters only
hi, does anyone know how to use PHP to take the first few words of a text and limit them? i have see

upload photo limits
ive got a upload photo script and im just trying to make more secure currently it limits size and as

Loops and Classes
I am making a template system and everything seems to be going well up until I have to loop in a var

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



Play Free Quiz and Win Cash