/ Published in: PHP
A simple PHP object which connects to a mysql database, selects fields, creates users and more..
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php class dbCon{ public function __construct(){ $server = "host"; $user = "user"; $pass = "pass"; $db = "db"; } function getFields($table){ $fields = $this->selectFields("*",$table); return $fields; } function selectFields($fields,$table){ if($fields != "*"){ } } return $chosenFields; } function createUser($names,$values){ $pass = ""; if($na[$i] == "password"){ } } $sql = "INSERT INTO users (".$names.") VALUES (".$values.")"; return "Account Successfully Created"; } function login($username,$password){ $sql = "SELECT password FROM users WHERE username='".$username."'"; $rs = mysql_query("SELECT users.id, users.first_name, users.last_name, users.email FROM users WHERE users.username='".$username."' AND users.password='".crypt($password, $cryptPass)."'"); foreach($row as $name => $value){ $userInfo[$name] = $value; } } return $userInfo; } function userAvailable($user){ } } ?>