Setup.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php namespace App\Controllers;
  2. use CodeIgniter\Controller;
  3. //use \App\Andy\Setupmodel;
  4. use \App\Models\Setupmodel;
  5. class Setup extends BaseController
  6. {
  7. protected $userName;
  8. protected $password;
  9. protected $role;
  10. protected $myTime;
  11. public function __construct()
  12. {
  13. parent::__construct();
  14. $this->myTime = parent::getTime();
  15. $this->myDate= date("d/m/Y",$this->myTime);
  16. }
  17. public function setUpForm()
  18. {
  19. $data =[
  20. 'title'=>'admin set up',
  21. 'date'=>$this->myDate
  22. ];
  23. //echo view('header',$data);
  24. echo view('setUpAdmin',$data);
  25. //echo view('footer',$data);
  26. }
  27. public function process()
  28. {
  29. $this->userName= $this->request->getVar('name');
  30. $pass= $this->request->getVar('password');
  31. $this->password = password_hash($pass,PASSWORD_DEFAULT);
  32. $this->role= $this->request->getVar('list');
  33. $handle= new Setupmodel();
  34. $handle->adminUser($this->userName,$this->password,$this->role);
  35. echo "done";
  36. /* please note the way its set up you can only have one admin user because db select gets first entry,si wont see anything else */
  37. }
  38. }