Jump to content

fear126

Members
  • Posts

    14
  • Joined

  • Last visited

About fear126

  • Birthday 10/15/1993

Contact Methods

  • Website URL
    https://taranpreetsingh.com

Profile Information

fear126's Achievements

Member

Member (2/5)

0

Reputation

  1. thanks it worked like a charm
  2. oh ok thanks i didnt get that in mind ill give it a try thanks for help
  3. Hi i am having trouble with my ajax code. It take 1st result data-id data and post to other page but it not doing that for all but there is all created exact same using foreach loop. Here is code and images foreach ($companySystem->getAllCompanyGroups($companySystem->getAllCompanyData()->id) as $value) { if(System::checkOddEvent($srNo) == true){ echo " <tr class='odd gradeX'> <td>$srNo</td> <td>".System::removeUnderscore($value->groupName)."</td> <td>$value->createdDate</td> <td class='center'>$value->createdBy</td> <td class=''> <button type='button' id='cmpEditBtn' class='btn btn-warning' data-id='".$value->id."' data-toggle='modal' data-target='#editCompanyGroup'><span class='fa fa-edit fa-large'></span> Edit</button> <button type='button' class='btn btn-danger' data-toggle='modal' data-target='#removeCompanyGroup'><span class='fa fa-ban'></span> Remove</button> </td> </tr> "; }else{ echo " <tr class='even gradeX'> <td>$srNo</td> <td>".System::removeUnderscore($value->groupName)."</td> <td>$value->createdDate</td> <td class='center'>$value->createdBy</td> <td class=''> <button type='button' id='cmpEditBtn' class='btn btn-warning' data-id='".$value->id."' data-toggle='modal' data-target='#editCompanyGroup'><span class='fa fa-edit fa-large'></span> Edit</button> <button type='button' class='btn btn-danger' data-toggle='modal' data-target='#removeCompanyGroup'><span class='fa fa-ban'></span> Remove</button> </td> </tr> "; } $srNo++; } Ajax : <script> $('#cmpEditBtn').on('click',function(e){ $.ajax({ type:'POST', url :"editCompanyGroupAjax.php", data: "id="+ $(this).attr('data-id'), dataType: 'json', success: function(data) { $("#previousCmpName").val(data.groupName); }, error:function(exception){alert('Exeption:'+exception);} }); e.preventDefault(); }); </script> Images : All working fine if i click on first edit button : Not working for other options sorry for bad english
  4. can i please email you full file so you can look over it ?
  5. problem is that the "?" in query are not getting replaced with the values i am supplying in array. But in function attachValues $para is having the arguments which are getting passed but they are not getting bind in query that is problem if you want i can send you whole file run and take a look on it
  6. no error just that query is getting generated Using input : $registerFields = array( "Name" => "qwerty", "username" => "qwerty", "password" => "qwerty", "email" =>"qwerty@qwerty.com", "active" => '1', "lastLogin" => "", "ip" => "", "resetToken" => "", "resetStatus" => "0" ); $userSystem->addNewUser($registerFields);
  7. i enter all columns names but still values are not getting bind in query :S string(154) "insert into `users` (`name`, `username`, `password`, `email`, `active`, `lastLogin`, `ip`, `resetToken`, `resetStatus`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"
  8. i need help i created a attachValues function which will attach values to sql query and execute it. I am using SQLITE database using PDO. Here is my code : private function attachValues($sqlQuery, $params = array()) { if ($this->_query = $this->_database->prepare($sqlQuery)) { $binder = 1; if (count($params)) { foreach ($params as $para){ $this->_query->bindValue($binder, $para); $binder++; } } if ($this->_query->execute()) { return true; } else { return false; } } return $this; } public function addNewUser($data = array()){ if (count($data)) { $keys = array_keys($data); $values = ''; $binder = 1; foreach ($data as $field) { $values .= '?'; if ($binder < count($data)) { $values .= ', '; } $binder++; } $sqlQuery = "insert into `users` (`" . implode('`, `', $keys) . "`) VALUES ({$values})"; var_dump($sqlQuery); if ($this->attachValues($sqlQuery, $data) != false) { return true; } } return false; } Error Message : with query dump string(81) "insert into `users` (`name`, `username`, `password`, `email`) VALUES (?, ?, ?, ?)" Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 19 users.active may not be NULL' in /home/u972751794/public_html/billing/classes/UserSystem.class.php:98 Stack trace: #0 /home/u972751794/public_html/billing/classes/UserSystem.class.php(98): PDOStatement->execute() #1 /home/u972751794/public_html/billing/classes/UserSystem.class.php(122): UserSystem->attachValues('insert into `us...', Array) #2 /home/u972751794/public_html/billing/login.php(69): UserSystem->addNewUser(Array) #3 {main} thrown in /home/u972751794/public_html/billing/classes/UserSystem.class.php on line 98
  9. I m using that following code but idk image is getting unable to upload $Destination = 'assets/images/avatar/'; if(!isset($_FILES['ImageFile']) || !is_uploaded_file($_FILES['ImageFile']['tmp_name'])) { die('Something went wrong with Upload!'); } $RandomNum = rand(0, 9999999999); $ImageName = str_replace(' ','-',strtolower($_FILES['ImageFile']['name'])); $ImageType = $_FILES['ImageFile']['type']; //"image/png", image/jpeg etc. $ImageExt = substr($ImageName, strrpos($ImageName, '.')); $ImageExt = str_replace('.','',$ImageExt); $ImageName = preg_replace("/\.[^.\s]{3,4}$/", "", $ImageName); //Create new image name (with random number added). $NewImageName = $ImageName.'-'.$RandomNum.'_'.$membername.'.'.$ImageExt; move_uploaded_file($_FILES['ImageFile']['tmp_name'], "$Destination/$NewImageName"); Please help
  10. i tried and founded that my find function is not getting user from db but still i don't find any problem with code can you please check my find and login function and correct them if wrong or can you come team viewer to my pc and remotely fix problem i really need it to work. public function find($user = null){ if($user){ $field = (is_numeric($user)) ? 'uid' : 'username'; $data = $this->_Database->get('users',array($field,'=',$user)); if($data->count()){ $this->_data = $data->first(); return true; } } return false; } public function login($username = null,$password = null){ $user = $this->find($username); if($user){ if($this->data()->password === Hash::make($password)){ if($this->data()->acc_status == '1'){ Session::put($this->_sessionName,$this->data()->uid); $this->_isLoggedIn = true; return true; } else{ Session::flash('error','Please check your email you need to active your account first.'); } } } return false; }
  11. i tried that code and this is what i got Input and token both get passed only idk why data not get in login function or login function have some error please check login function i think there is some error which i cant find
  12. thanks for help ill give it a try and post my views soon thanks
  13. Hello i am new to think community but look like here i can find solution for my problems by good programmers all around the globe. Here is my problem I make a login function and just trying to use it it not giving any error but it also not working rest all function in that class is working fine. here is code and output screen. [user class login function] public function find($user = null){ if($user){ $field = (is_numeric($user)) ? 'uid' : 'username'; $data = $this->_Database->get('users',array($field,'=',$user)); if($data->count()){ $this->_data = $data->first(); return true; } } return false; } public function login($username = null,$password = null){ $user = $this->find($username); if($user){ if($this->data()->password === Hash::make($password)){ if($this->data()->acc_status == '1'){ Session::put($this->_sessionName,$this->data()->uid); $this->_isLoggedIn = true; return true; } else{ Session::flash('error','Please check your email you need to active your account first.'); } } } return false; } Here is login.php code $user = new User(); if(Input::exists()){ if(Token::check(Input::get('token'))){ try{ $login = $user->login(Input::get('username'),Input::get('password')); if(!$login){ Session::flash('login_error','Unable to login.'); }else{ Session::flash('logged_in','Logged In Success'); Redirect::to('home.php'); } }catch(Exception $e){ die($e->getMessage()); } } } Screen shot:- I really want this login code to run!. Thank you
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.