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

Entering Data Problem
Code: $result = mysql_query("SELECT * FROM flights");
while ($row = mysql_fetch_array($

Preloading images
Posting this question here because I am not sure where this should belong.I am building an asp.net a

please help
HTML Code:

Code: <span id="ctl00"><span>

checkbox update
I am having a brain fart right now and i cant remember how to do this. if anyone could help that wou

Slashes
Have a small problem and I'm not able to understand why I'm getting the results I'm getting... and i

How to Detect it is public_html or httpdocs?
How to check whether it is cPanel or Plesk?

If it found public_html perform <?php incl

b+ tree
Hi
can every body help me about b+ tree ?(insert & delete)

Paypal
Hi all,

I have an advanced basic knowledge of php

I want to try something new for a s

ImageCreate()
When I create an image and add text to it I want my text to be replaced with a PNG image, because th

How to assign a textbox value to PHP variable??
Hi ! Can any one help me out as quickly as possible. As I m new to PHP.
Plz tell me how to assign

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