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

Packet Design
Hi All,
Im new about network programming and I want to design a protocol but I have some question

ereg_replace issue
hi there people

i have this code happening with regards to my wamp server. is this something

Else statement screws up all css
Does anyone know what goes wrong in the process with this php code?
This code seems to be causing

Request-URI Too Large
I have created a simple submit form for a mysql database that puts a piece of code into database.<

php code generators
All

Whilst enjoying learning a new language i have come accross a number of free code generat

Just a white page
Okay so, my website, when I click SignUp on it it takes me to /join.php but its a complete white pag

Cache PHP Objects/Classes?
Does anyone have ideas about caching PHP objects using something like: http://memcached.org/

Are sessions secure at all?..
I haven't really gotten into yet, but I was just thinking of something weird..

Lets say you h

Wordpress IE issue
So I am trying to add the background shadow to my wordpress page. It works fine in Firefox but does

php require help needed
Ok i tried to use the search funtion but the word require is everywhere.

i'm really new to cr

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