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

how can i expire the submitted page using session.
hi,
i'm new to php world.
i'm using "post" method.
when i submit it,data goes to

How to search for several parameters from objects in a database?
I have a database with lots of information about objects.
Now I would like to search for 4 or 5 p

Session variable help
I'm having a very troubling issue. Maybe I'm just looking over something but I have looked at the co

Spaghetti Code
So.

I've pretty much reached the point where I have so many isset s on one page that I can't

download directory onto C drive
I am attempting (if this is possible) to write a routine to automatically dump the contents of a dir

help with insert
Hi there,

I am trying to insert some data into a database, but for some reason, it is not ins

convert static html data into dynamic
hi all

i need to convert a website which has static above 2000 articles into dynamic and add

Allowing ' and "
Hello everyone,

I am creating a form where users submit information to go into a database. I

natcasesort works on one server but not on another
Hi

I have a problem that I was hoping that someone can help me with.

I'm trying to use

media recovery
Hi,
i startup the database i got the error

SQL> startup
ORACLE instance started.

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