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

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

How do I give a developer access to a specific directory and nothing else?
I want to give a develop access to a specific directory and nothing else

I can give them an F

INSERT data problem!
After having an string with apostrophes ', double quotes " or any other special characters, suc

SESSION question
I am building an application , a directory for auctions.
For SEO i made a script which copies a p

Need help making a blockquote and line items conditional
I have some code I bought a few years ago that allows my clients to update content on their site usi

button.click += new eventhandler() not works in if(!ispostback)
i want to use button.clcik event in function VIewScrap() which is called in if(!ispostback) but itdo

Creating XML with php
I need to creat an XML with php and have successfully produced a valid output.
The problem I hav

line breaks in between fetched file names
Hi,

I have this code:
Code: <?php
if($dir = opendir('files')){
while (($f

Simultaneous select/update/insert
Hi

How would I need to go about when 2 users update a single row simultaneous? And how would

send message to the java application
Oracle 10g with Windows platform.

I have a java application that periodically pings the d

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