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

some query on multilingual website
Hi all,

Which is the simplest and easiest method to make a website multilingual,
is it put

Help building / using array
First - this is a cross-posting, if this is wrong I apologise! What started out as a MySQL query que

Unidentified index error in a simple form
I have been trying to make an HTML form that is handled by a PHP script. So far my attempts to get i

Automatic Webpage ??
I have a page www.mysite.com/test.php with a
<form>
<textarea name=&q

i want run some web server under the ip sharer
hello i want run some web server under the ip sharer
my ip is floating ip but it doesnt matter

* Gridview and Detailsview in UpdatePanel, insert mode problem
I have a GridView and DetailsView working together. When a record from Gridview is selected, Detail

parsing error
can anyone explain this syntax error:

Parse error: syntax error, unexpected T_IF

The e

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

Checking BOM Authorization Group
Hai Friends,

I have developed a mulitilevel BOM display report. End users have been assig

Accessing Infotype data in dialog program
Hi All
In Dialog programs attributes I didn't see any logical database field. How can I access

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