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

Did you know?Explore Trending and Topic pages for more stories like this.
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

Sequencing or queuing parallel process
Scenario is as follows
There is one parent process say P1 and 4 child processes say A B C D

Need help in Generating Combinations
Need help generating all possible combination of names in an array

Lets say i have the follow

Port scanner problem
Hai
recently i developed one app through which u can check the opened and closed ports under an

split values
I have values that are returned to me in this format:

name=>test,age=>49

php multiple action on submit
I have a form which says:

<form enctype='multipart/form-data' method='post' action='pr

can i optmize image to 50% quality before uploading 2 server
Hi there

i have jus written a php program to upload and display images but when i try to uplo

MySQL issue
I am taking sentences through a form on page. Then checking some condition and trying to insert them

AutoChoosing a CSS file based on URL
Hey everyone,

I have a site that has multiple URLs and CSS files.

Based on the URL tha

Need help with a mail notify function
I was tasked with setting up a site that's been prewritten. The site is basically a form that captur

help with this code please?
Hello,

I am trying to build a remote upload script for my image hosting site.

I am usi

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