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

do while...woes
I'm sure this is childsplay but it is stumping me, everytime i try what I think would make this work

The page should be expire when cilck back button
hi,
i'm new to php world.
i create user registration page.
when i submit it,data goes to my

image upload script not working with png
The basic process of this php code is to take the submitted file, convert it to a small JPG thumbnai

Generate multilayered array from string.
ok so i have a string that looks like this:
Code: [Select]blog:edit_all,delete_all|users:edit_all

OPINIONS WANTED
This is my login page code, and I want your opinion on it please!

Code: // Login ~ CHECKS

Material xxx does not exist in plant xxx
Dear All,

I am working for a steel project which is repetitive manufacturing.

Help with php code
Hello, can anyone tell me why this php word trap fails to work,
and the trigger words get blow r

Pop-up Banner
Hello Friends,I need to use banner in our client site.Example: www.example.com if i enter this site

array_count_values question?
ok i'm trying to create a top ten list from a database of listed favorite movies.

the followi

building a function with multiple outputs
I want to build a function that has multiple outputs.

I know but am not to sure how I should

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