Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //config-db.php
- define('DB_SERVER','localhost') ;
- define('DB_USER','root');
- define('DB_PASS','toor');
- define('DB_DATABASE','myweb');
- ?>
- <?php
- //userAPI.php
- include "config-db.php" ;
- class userAPI{
- public $db;
- function __contruct(){
- $this->db=new mysqli(DB_SERVER,DB_USER,DB_PASS,DB_DATABASE);
- if ($this->db->connect_error){
- die ("error connect database!");
- exit;
- }
- }
- function login($username,$password){
- $select=$this->db->query("select * from users where username='$username' and password='$username'") or die ("c'ant select!!");
- if($select->num_rows>0){
- return true;}
- else{
- print "خطأفي الاسم اوكلمة المرور";
- return false;
- }
- }
- function update($username,$password,$id){
- if (!isset($id)){
- print "bad request";
- }
- $id=intval($id);
- if ($id='0'){
- print "bad request";
- }
- else{
- $select=$this->db->query("UPDATE users set username='$username' and password='$username' where id='$id'") or die ("c'ant select!!");
- }
- }
- function select(){
- $select=$this->db->query("select * from users where id='$id'") or die ("c'ant select!!");
- $fetch=$select->fetch_array('MYSQLI_ASSOC');
- $username_db=$fetch['username'];
- $password_db=$fetch['password'];
- $id_db=$fetch['id'];
- $lvl_db=$fetch['lvl'];
- }
- }
- $dz=new userAPI();
- $dz->login('dz','dz');
- ?>
- :========problleme=========:
- Fatal error: Call to a member function query() on a non-object in /var/www/html/site/admin/functions/userAPI.php on line 19
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement