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

phpMailer will not connect using SMTP
I am trying to use phpMailer with smtp:

Code: [Select]$mailer = new PHPMailer();
$mailer-&

Only add new information from XML to MySQL
What I am doing, is taking a xml file, and adding the values to a database. However, what I want to

getting weird error..
okay, I'm getting an error on this particular function, something about the syntax in the mysql LIMI

An odd assignment statement. Can someone explain this assignment to me?
What purpose is served by the bit of code between the two equal signs in the $installurl set? Is th

help with Get_
ok some how this is not working i am not sure what i am doing wrong here but what this does is when

Warning: mysql_num_rows() expects parameter 1
When i add quote at the end of this link
example:http://localhost/articlemania/category.php?cid=3

FFmpeg Images 2 Video conversion problem ??
I got folder full of images , number of images = 600 , I want to make a video which plays one image

How do I use a global footer..?
If my index.php has a bole bunch of if functions and exit's in them

WELCOME SCREEN
first of all let me tell you what does my script do,

it´s a very simple query to show a e

Need help in log in and log out?
hi there all of u. i have recently created a site for someone. i have placed log in and log out and

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