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

Simple program to copy files between two computers over the web
I use logmein free and often need to move files between my two computers. Generally, I move the file

Table sorting
Hi,

I'm trying to modify the following in order to make the output table sorted alphabeticall

How to make a input/output field with multiple lines
Hello.
I put a input/output field on the screen but I could not change height of it. I need to

Multi-user card game
I'm writing a batch of games and such. Lottery is finished, Poker,blackjack,etc are next. They will

quick question
Hi ..

i have a question
how do i set a var so it displays via an echo
Code: $logo = '&a

News script
Hi ...

I am not sure if this is the rite place to post this but if its not sorry

i am

Sending CC Info by email
I am a little bit less knowledgable in the security area as most developers and I know I have a lot

Help with looping
I have a comma separated list of colors taken from a database ($ICo) and a directory of images named

PHP page is blank
Hi Everyone,

I have a site in which I am able to open the first PHP webpage in my browser but

Delete HTML file after loading
I have limited experience with php and its been a year or two since I've last used it. I have a sma

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