php - SQLSTATE[42S02]: Base table or view not found: 1146 Table X doesn't exist -


i getting error in laravel 5:

sqlstate[42s02]: base table or view not found: 1146 table 'intern.users' doesn't exist (sql: select * users username = admin limit 1)

config/database.php

        'mysql' => [     'driver'    => 'mysql',     'host'      => 'localhost',     'database'  => 'intern',     'username'  => 'root',     'password'  => '',     'charset'   => 'utf8',     'collation' => 'utf8_unicode_ci',     'prefix'    => '',     'strict'    => false, ], 

the function admin called admin page, , database table mentioned in admin because there many tables in it.

    public function admin(request $request){             if($request->ismethod('get')){            return \view::make('student.admin');         } else     {           $check=0;         $check=\db::table('admin')->get();         $username = input::get('username');         $password = input::get('password');         $data=array(      'username'=>$request->get('username'),      'password'=>$request->get('password')     );      if(\auth::attempt($data))     {         return redirect::intended('student/index');     }     else     {         return redirect('student/admin');     }           }              }     

form here:

  <div id="pagecontent"><br /> <div align="left" style="margin-left:24px;">   <h2>please log in manage</h2>   {!! form::open(array('url' => '/admin')) !!}   <input type="hidden" name="_token" value="{{ csrf_token() }}">       user name:<br />       <input name="username" type="text" id="username" size="40" />     <br /><br />     password:<br />    <input name="password" type="password" id="password" size="40" />    <br />    <br />    <br />       <input type="submit" name="button" id="button" value="log in" />    {!! form::close() !!} 

first should hash , create user details make coloumn ready authentication.

here have given steps achieve it.

step 1 : input

$userdata = input::all();

step 2 : create entry - inserting user table

user::create($userdata);

note :

you should have these following coloumns in users table

  1. email,
  2. password
  3. created_at
  4. updated_at

additional setup :

have line in user.php (model)

protected $fillable = ['email', 'password']; 

here's tiny login code simple enough you

have try on if wish

$email = $this->request->input('email'); $password = $this->request->input('password'); if (auth::attempt(['email' => $email, 'password' => $password])) #if credentials right {  return redirect::intended('student/index'); #your success page } else {  return redirect('student/admin'); #your failure page } 

recommendation :

i recommend validate user input before creating

additional note :

if see table , if password encrypted , means you're done ;)


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -