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

Setting/Modify Headers using mail() function
I have a question about setting email headers when using mail() in a php script.

When I send

problem with php mysql query
Hi guy's...

I'm totally lost here..because don't have any idea how to make a query for grab r

PHP Surveys
I really would like some advice.

If you have a client come to you asking for a survey to be d

multipart emiail forms
Hi All,

I am new to the boards and I've been working on a form (which is rather massive, imo

selection tool on raster image
Hi!
I have to implement in my app a selection tool which lets users to select region of any shape

admin with my register system?
Hey i wana make it so i can make a admin level on my register system , I'm kinda new to php to im no

How to add advertisment on top of videos
Hello,
I was told that i should find the answer for this problem in this forums.
I searched a

recrawling
Can anyone suggest me how may i know a page is updated before it is being downloaded, so that i can

PHP Include not working
The website is http://www.grlistingservices.com

The code block is as follows:

<

Confusing Functions
So, I've been reading up on Functions and I like them! However, I need some help using variables in

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