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

problem with array - multilingual page
this is my test page :
Code: <?php
if(isset($_GET['lang'])) {
if($_GET['la

comparing tables across databases sql refinement ideas required
Hi all

Via pl/sql I need to ensure that data between tables in different databases match

Disable html within defined tags
I have a mysql database that allows users to enter content with html, but I also want to have a tag

How to show next and prev records
Hi all,

Sorry if this is simple, i'm very new to php, well, any programming language actually

server trace logs
could any one tell me from where do i get error logs in xMII??I want to check the reason for dtabase

start new row of pictures
on my site www.budstreasureauctions.com there is a featured auctions box that users will pay to get

PHP/Database issue
My friend is helping me make a database where you go to a certain webpage of my site and the page wi

Cloud Computing?
Hello,

I was wondering if anyone could help explain this term to me. I'm starting to hear it

Simple AND question
Hello,

I've got following code:

Code: if(strpos($row[13],"http://")

Conditions of info record - Error
When i created GR (901) and PO create automatic my PBXX is obtain the net price of info record but

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