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

Filename and Line Number Custom Error
I have a class, with a method that accepts 2 parameters. I would like to output error messages.

keeps going back to index.html ???????
ok so i started making my site using mostly.html files now i have added a fair chunk of php. My inde

Create PHP table grid help, please
I have a MySQL database setup, now it's time for the table (gridview) design in php. Here's the prob

help with calculations on a flat text file
hello,
I have this code below that is attached to a flat file like this:
Email:LastName:FirstN

UTL File problem
Hi
I have a file in certain path with the following permissions (The file is a dummy file witho

re calling a function without including file
Hi,
i am new to programming in php, i was just checking the wordpress code and found out in the w

Socket Server
In my following socket server, I am trying to listen to a connection through port 12345 in my web br

What am I missing here? Help!
Hello all!. I can't seem to get this working right. Well - it renders right, but something is goin

Material Issuing for receiving batch
Dear All experts in MM/ PP,

Material issuing from main stores to factory is currently usi

How to add functionality to a simple php calender?
Hello everyone,

I have just finished creating a simple php calander. Can someone point

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