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

help with insert
Hi there,

I am trying to insert some data into a database, but for some reason, it is not ins

Pagination won't carry results past page 2.
Hi all,

I've worked out my pagination script and its paginating fine until I click next from

Recode Abap Dynpro into Web Dynpro
Hi All,
A client has asked us to look at rearchitecting a custom transaction that was developed

Help with parsing this html
Hi,
I've got some html i just need a couple of strings from.. argh, it's freaking me out. I've t

I need some help with the IF command...
I have a large number of images in one section of my website with the .jpg format. I'm adding a bun

parsing error
can anyone explain this syntax error:

Parse error: syntax error, unexpected T_IF

The e

php/xmlrpc class issue
I am working on xml-rpc in php to start with.

I have a class that only has variables defined

Embed Video Problem
Hey, thanks for looking!

File to be embedded:

Code: <playlist version="1&q

help, header() is not working!
Hello, I have this code:


<?php

/**
* @author samoi
* @copyright 200

AUTONUMBER PROBLEM
Hello Everyone,

My name is Jones and i am new to this forum and to oracle. I am using ora

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