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

Help With editting and deleting form
Hallo !!

So look at this image :

http://img194.imageshack.us/img194/8272/snapshot5f.pn

php call servlet
I have done a php backup application .
So there is a form that user pick some files to zip and d

login box shows up again after logging in 2nd login works
Hello,

I am having trouble on my site Lockerz.rack111.com where when you login the login box

Web Application Recipe
Hi Guys!

I am working with the Web Application recipes. I am currently working on the sen

Not adding to db
Hi, I can't figure out why it won't add the record to the database. It's just a simple form to get

Help on code output
My CODE:

Code: [Select] echo "<phone>".$line["phone"].&qu

Help with echo()
I'm having some problems with this code:

Code: echo '
<A HREF="jav

Connecion issue
Hi,

For some reason, I keep getting this error when trying to connect:

Warning: mysql_

frame help
on the bottom frame is menu.html

Code: <body><form action='link.php' met

DateObject and Nulls
Hi all,

I have an array mapped to a value object. One of the items in the array is a PHP Date

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