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

Converting numbers to months
The porgram works -just need the last function(month_convert_ to convert numbers to months -thanks.

PHP Tab Control
Hi All,

I would like to have PHP tab control with/without Javascript.

But I want to r

Save cookie to DB
I'm working on a pixel tracking script for an incentive website and I need to use an ASP script to s

Send inserts to mysql thru port 80
Hi!

I have an application that must do some inserts in a mysql db. This db is behind a firewa

extract data
Code: <div class="post hentry uncustomized-post-template">

records between 2 dates
Hello all,

I have a date tracked table which contains effective_start_date and effective

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

Help on query replacing the date
Hi Pals,

i want to replace the current date in a column to some value say C or D or any n

Login logout link help
Hi all,

Im new to php and Im having trouble creating a login/logout link for my page that dis

Problem with PHP/mySQL login code
Hello,

There is an error in my login script and I can't figure out what it is...
I believe

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