Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

laksh's avatar
Level 1

Input::get('email') giving error

Error : Call to undefined method Symfony\Component\Console\Input\Input::get()

public function process_login(Request $request) { $request->validate([ 'email' => 'required|email', 'password' => 'required' ]);

    $userdata = array(
        'email' => Input::get('email'),
        'password' => Input::get('password')
    );
    
    
    if (Auth::attempt($userdata)) {
        
        return response([ [1] ]);
        
    }else{
        
        return response([ [0] ]);
    }
    
}
0 likes
47 replies
Sinnbeck's avatar

Do this instead

    $userdata = array(
        'email' => $request->get('email'),
        'password' =>$request->get('password')
    );
1 like
laksh's avatar
Level 1

Thanks it is worked But that condition is not getting true can you please explain why?

if (Auth::attempt($userdata))

laksh's avatar
Level 1

@Sinnbeck what is this used for I can't able to login using this but got some response dd($userdata)

laksh's avatar
Level 1

i can't able to post that response here

Sinnbeck's avatar

@laksh No need to post it. Just check that the email and password is what you expected. Lets say password is an empty sting, then that would be the problem.

laksh's avatar
Level 1

@Sinnbeck no password is not empty i am getting password string but dont able to login

Sinnbeck's avatar

@laksh Now that you are writing your own login login, did you also write your own sign up logic? Is the password hashed in the database?

Sinnbeck's avatar

@laksh Ok time to see if you can sign in at all. Open php artisan tinker in a commandline

Now test this. I assume you are using a dummy password while developing and not a password you actually use anywhere else. If that isnt the case, then change the password before testing (or recreate your user)

Auth::attempt(['email' => '[email protected]', 'pasword' => 'yourtestpassword']);
Sinnbeck's avatar

@laksh Then it seems that the user in the database cannot be logged on using those credentials. How are you creating users?

laksh's avatar
Level 1

@Sinnbeck i am using code for registering users into database

public function process_signup(Request $request) {

    $request->validate([
        'name' => 'required',
        'password' => 'required|min:8',
        'email' => 'required|email|unique:users,email'
    ]);
    
    $user = new User();
    $user->name = $request->input('name');
    $user->email = $request->input('email');
    $user->password = Crypt::encrypt($request->input('password'));
    $user->save();
    
    $request->session()->put('user', $request->input('name'));
    
    return redirect('/');

    
}

through this i am registering users

Sinnbeck's avatar

@laksh You should has the password, not encrypt it

Hash::make($request->input('password')),
Sinnbeck's avatar

@laksh Ok use dd() to see how far it gets in the code. Im having a hard time helping if I dont know what happens.

laksh's avatar
Level 1

@Sinnbeck

public function show_signup_form(){ return view('maincontent.register'); }

public function process_signup(Request $request)
{
    
    $request->validate([
        'name' => 'required',
        'password' => 'required',
        'email' => 'required'
    ]);
    
    $user = new User();
    $user->name = $request->input('name');
    $user->email = $request->input('email');
    $user->password = Hash::make($request->input('password'));
    $user->save();
    
    $request->session()->put('user', $request->input('name'));
    
    return redirect('/');

    
}

okk see i got two function one is for showing form and second is for processing or saving data into database but my second function is not calling

Sinnbeck's avatar

@laksh Do you hit the process_signup at all? Add dd('hit'); at the start of the method and submit the form.

laksh's avatar
Level 1

@Sinnbeck

Route::namespace('App\Http\Controllers\Auth')->group(function (){

    Route::get('/login','LoginController@show_login_form')->name('login');
    Route::post('/login','LoginController@process_login')->name('login');
    Route::get('/register','LoginController@show_signup_form')->name('register');
    Route::post('/register','LoginController@process_signup')->name('register');
    Route::post('/logout','LoginController@logout')->name('logout');
});
Sinnbeck's avatar

@laksh You have 2 routes with the same name. That isn't allowed. (you have this twice)

An example

    Route::get('/login','LoginController@show_login_form')->name('login');
    Route::post('/login','LoginController@process_login')->name('login.post');
    Route::get('/register','LoginController@show_signup_form')->name('register');
    Route::post('/register','LoginController@process_signup')->name('register.post');
    Route::post('/logout','LoginController@logout')->name('logout');
laksh's avatar
Level 1

@Sinnbeck it still doesn't working if i changed their name can you suggest any other option thanks in advance

Sinnbeck's avatar

@laksh yeah I suggest learning the basics of laravel before trying to write your own auth. Currently you are struggling with routing and forms which are basic laravel

Maybe start with "laravel 8 from scratch". It's free

Once you get your route and form to work, this should work

1 like
Sinnbeck's avatar

You can also create a seperate thread where we can help you with your routing. As I understand, the problem is that you never hit the method on the controller, so it's not really related to your original question

laksh's avatar
Level 1

@Sinnbeck but before i changed encryption to hashing it was working can you suggest whats the reason behind that?

Sinnbeck's avatar

@laksh well if you are adding dd() at the top of the method then it shouldn't matter. Maybe share how the file looks now

laksh's avatar
Level 1

@Sinnbeck Here is the code

public function process_signup(Request $request) { dd('hit');

    $request->validate([
        'name' => 'required',
        'password' => 'required',
        'email' => 'required'
    ]);
    
    $user = new User();
    $user->name = $request->input('name');
    $user->email = $request->input('email');
    $user->password = Hash::make($request->input('password'));
    $user->save();
    
    $request->session()->put('user', $request->input('name'));
    
    return redirect('/');

    
}
Sinnbeck's avatar

@laksh looks fine. Now find out what url and method your form for creating users use

laksh's avatar
Level 1

@Sinnbeck the function which i made for creating the user is not calling so what can i do now ?

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@laksh check the browser html as I just suggested. Visit the register page. Open f12 and elements tab. Check your form action and method

laksh's avatar
Level 1

@Sinnbeck yeah and it looks fine i don't know what's the problem behind its not working?

Sinnbeck's avatar

@laksh could you share it? I cannot really help in any way if I don't know your code

laksh's avatar
Level 1

@Sinnbeck my registration form is working now it starts saving data into database

laksh's avatar
Level 1

@Sinnbeck yeah its working now login and then redirecting to the dashboard Thankyou.

laksh's avatar
Level 1

@Sinnbeck No, my column name is email in database and on changing to mail i am getting error on changing to mail

Sinnbeck's avatar

@laksh Yeah I was mistaken an have asked a relevant question instead :)

Please or to participate in this conversation.