Access database inside of a validation class


Posted on 16th Feb 2014 07:03 pm by admin

Hello,

For quite some time, I have been using functions to validate form input and access the databse. I have recently started using OOP, which is far faster and better when it comes to programming (performance aside).

Did you know?Explore Trending and Topic pages for more stories like this.
My question:
How do I access the database within a specific validation class.

Example:

class validateLogin {

// Class properties
public $value;
public $msg;
public $valid = 0;

// Access database and do some stuff to check

}

I added in the "public" to show how I would get values into the class from the public variable scope. Would I do the same for the database? A problem would arise because I use a database class to access mysql. Can I have a class within another class? I could use a normal function and basic coding, but I like php classes. Thank you
No comments posted yet

Your Answer:

Login to answer
56 Like 23 Dislike
Previous forums Next forums
Other forums

Undefined index on my form
ok im getting Undefined index on this line.. print_r($_REQUEST['form']);

below is the full sc

classic dynpro : hide area and auto adjust hights
Hi,

I want to develop a similar user interface as is used in standard transaction MIGO.

Undefined offset
The following script checks to see if the user answer matches the correct answer.

Form Fiel

Help with lottery style system?
I'm working on a currency system for forums and it is going to have a type of lottery system built i

HTML form problem
Ive made a form to that i want to send to my email via PHP. but when it send only the name's etc sen

Text to picture Generator
Hello, i have found this script and it works really good^^ But i have one problem, i would like to c

Record count of entire database
Does anyone know if there is a way to obtain the number of records in each table of the database usi

Exporting new records
Trying to figure out the best way to set this up.

People register my site.

Their prof

rookie looking for help coding a CSS form with PHP
I'm trying to figure out how to add PHP code to my xhtml form so that it is a working form embedded

parsing error
can anyone explain this syntax error:

Parse error: syntax error, unexpected T_IF

The e

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