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

include function being weird?
I have a very simple system to grab an IP outputted by a PHP file.. (for a project I have) but it ou

Namespace Problem
I'm having problem with a section of code with a variable namespace.

This code works fine:

rdns with php
I am trying to build a script that will show all of the different domains that are hosted on the sam

this code is strange !
Hi i got this code from the web.. It checks for live and dead socks
It is working perfectly on my

Default TimeZone
The server I'm working with is hosted in America so all times inserted into the database are coming

GET * FROM _____ Except?
I have a site that is for stock photography.

This section of the code calls images to display

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

Socket Server
In my following socket server, I am trying to listen to a connection through port 12345 in my web br

Error in Configure System Landscape Directory phase
Hi

We are getting the error in Configure SLD phase ( 41 of 44 phase).

Please f

Array to string conversion
Can anyone help me with this?

Notice: Array to string conversion in /home/..../index.php on l

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