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).

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

isset undefined variable
Hi all,

Hope someone can point out the obvious. I've a log in script, if you dont enter a use

change text color with a jQuery code
Hihow can I change the text in a asp:TextBox to a different color when I start typing using jQuery?I

FPDF Help
I've been playing with the FPDF module. I was building a form and rolling right along and then sudde

xml element exists
Code: [Select]<?xml version="1.0"?>
<Addresses>
<

FTP issues
Hi all,


I am currently facing some serious problems with a script and really need some ad

How to implement HTTP connection timeout
Hi All,I would like to implement an HTTP connection timeout.

I am working on a application wh

login form can you find my error?
registrationform.php seems fine send data to registration.php
registration.php seems fine checks

Price in PR
Dear Experts,
Why we have to enter the price in the PR, and why there is no free goods indicato

My XSRF Prevention code isn't working
First of all, thanks for the generous help you guys have given me in the past on this forum.
Seco

Embed Video Problem
Hey, thanks for looking!

File to be embedded:

Code: <playlist version="1&q

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