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

Did you know?Explore Trending and Topic pages for more stories like this.
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

check if value exists
I have googled this for a while and I am getting lots of different results. Is there a standard meth

Image DPI
Hi.

I allow users to upload images, the user then is able to adjust several settings for the

sapgui f4 help last search
I know this has to be simople. One user (maybe more) does not have the "last search saved" from the

How to have a log of all the status a VIM document had been ?
Hi guys,

I’m using SAP Invoice Management plugin and the /OPT/VIM_ANALYTICS transa

User registration and login
I don't know whether this is the correct forum, if not i apologise but am pretty desperate at the mo

listing help
Hi,

at first, great new design!!! I like it,

i got a problem,

I want to list so

How to write on database when a link is clicked?
Hi, I have a list of products in a gridview. When the link is clicked currently it takes to an ext

Multipe Dynamic Controls & AutoPostback Issue
I currently have a need to create many dynamic controls (Example Textboxes) that need to do a PostBa

get url?
how do i get the url of the page i'm currently on, on my website.. i think its get header.. how do i

printing links
Hi every1

i am connecting to a table in sql and the looping through with a while ($ var = my

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