Hi guys
I have a query regarding how to do this
say for example i have 3 or more classes
connections.php
users.php
login.php
now
in each of these files is the following.
//In our login page we have the usual code if isset etc..
include_once('users.php');
if(isset($_POST['Submit'])){
$newuser = new user;
$newuser -> setlogin($_POST);
}
include_once('connections.php');
class user {
public $username;
public $password;
public function setlogin($_POST){
$this->username = $_POST['username'];
$this->password = $_POST['password'];
// Now i want to send these details to connections.php
$newconnection = new connection;
$newconnection->checkdb("SELECT * FROM `users` WHERE `username` = '".$this->username."');
}
class connection {
private $username = "root";
private $password = "";
private $server = "localhost";
private $db = "users";
private $connectionlink;
private function connect(){
$this->connectionlink = mysql_connect($this->server,$this->username,$this->password);
mysql_select_db($this->db,$this->connectionlink);
}
public function checkdb($sql){
mysql_query($sql);
if(mysql_num_rows($sql) == 0){
echo "no results found";
}
}
How can i do this please?
Im quite new to using Classes in PHP , So there may be some small errors there.
Also i know theres no MYSQL_REAL_ESCAPE_STRING on the posts for SQL injections but as this is a dummy script i wrote as i was posting i didnt bother with that 🙂
Many Thanks Pink.