Do this instead
$userdata = array(
'email' => $request->get('email'),
'password' =>$request->get('password')
);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
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] ]);
}
}
Do this instead
$userdata = array(
'email' => $request->get('email'),
'password' =>$request->get('password')
);
Thanks it is worked But that condition is not getting true can you please explain why?
if (Auth::attempt($userdata))
@laksh use dd($userdata) to check if the data is correct
@Sinnbeck what is this used for I can't able to login using this but got some response dd($userdata)
i can't able to post that response here
@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.
@Sinnbeck no password is not empty i am getting password string but dont able to login
@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 yeah password is hashed into database
@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 i am getting false result on trying this code
@laksh Then it seems that the user in the database cannot be logged on using those credentials. How are you creating users?
@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
@laksh You should has the password, not encrypt it
Hash::make($request->input('password')),
@Sinnbeck i don't know why but my register form stops working
@laksh DId you import Hash?
use Illuminate\Support\Facades\Hash;
@Sinnbeck yes
@laksh Ok. Explain "stops working". Error?
@Sinnbeck it doesn't giving an error infact my form doesn't submitted
@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.
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
@laksh Do you hit the process_signup at all? Add dd('hit'); at the start of the method and submit the form.
@Sinnbeck no it doesn't submitted at all by using dd('hit') also
@laksh Show the form and the route.
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');
});
@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');
@Sinnbeck it still doesn't working if i changed their name can you suggest any other option thanks in advance
@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
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
@Sinnbeck but before i changed encryption to hashing it was working can you suggest whats the reason behind that?
@Snapey well spotted :)
@Snapey sorry i can't understand what you mean to say?
@Sinnbeck i couldn't understand
@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
@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('/');
}
@laksh looks fine. Now find out what url and method your form for creating users use
@Sinnbeck the function which i made for creating the user is not calling so what can i do now ?
@laksh check the browser html as I just suggested. Visit the register page. Open f12 and elements tab. Check your form action and method
@Sinnbeck yeah and it looks fine i don't know what's the problem behind its not working?
@laksh could you share it? I cannot really help in any way if I don't know your code
@Sinnbeck my registration form is working now it starts saving data into database
@laksh ok awesome! Is it working then?
@Sinnbeck yeah its working now login and then redirecting to the dashboard Thankyou.
@laksh great. Please mark best answer to set the thread as solved
Please or to participate in this conversation.