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

type check while uploading
Hi Everyone,

How can I check the exact type of a file while uploading on my site?

Here

Curly Bracket Delimeters.
I'd always believed that the starting and ending delimeters in preg_ functions had to be the same ch

Email with Attachments in PHP
Hi Friends

How to send email in PHP with attachment.
I know simple mail can be sent with

PHP/Database issue
My friend is helping me make a database where you go to a certain webpage of my site and the page wi

Material Issuing for receiving batch
Dear All experts in MM/ PP,

Material issuing from main stores to factory is currently usi

breaking a text file into paragraphs based on strings
I have a text file of email addresses that is all squished together. It looks like this:

abc

help removing unwanted graphic
How do I remove the small elongated rectangular shape between the "Latest post" and "

Printing issues with xMII 11.5
For some reason, we have one report (and only one) that is giving us fits when trying to print. The

Securing a user input - need some confirmation
Hello All,

I am in the process of recoding a large proportion of an e-commerce site, one of t

jquery validation in codeIgniter
hai i need to add client side validation to my fiels which are selected in a forloop.the fields are

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