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

mozew's avatar
Level 6

How to enter session code number?

@PSYLOGIC - Thanks for answer. After register redirect to this page.

I want enter this code. (Of course mobile number and the code save in database and send a sms to mobile).

How to enter session code number?

Code

public function send(Request $request)
{
    $code = $request->code;
    $mobile = $_GET($request->mobile);
    $user = User::whereCode($code)->whereMobile($mobile)->first();
    if($user){
        $user->verification_code = 1;
        $user->save();
        alert()->success('ok');
        return redirect()->back();
    } else {
        alert()->error('error');
        return redirect()->back();
    }
}

I have verification_code in users table. I want In case of enter true code and mobile number, verification_code change to 1

0 likes
15 replies
Snapey's avatar

what the heck is this?

$mobile = $_GET($request->mobile);

why don't you just do it as the previous line?

$mobile = $request->mobile;

infact why do you need these temporary variables at all?

$user = User::whereCode($request->code)
    ->whereMobile($request->mobile)
    ->firstOrFail();
mozew's avatar
Level 6

@CRONIX - I changed

public function send(Request $request)
{
    
    $code = $request->code;

// $mobile = $_GET($request->mobile); $mobile = $request->session()->get('mobile');

Is it correct now?

siangboon's avatar

within few days asked so many questions some even well documented, just wonder whether you really think and develop on your own or just take the helps from all the folks here to complete your works?

jlrdw's avatar

In another post I pleaded with the OP to learn some of this stuff so he would know it and it's in his mind, and not just copy and paste code.

Is it correct now?

You don't have any confidence in Taylor and the examples he put in the documentation.

If you do some of the stuff just like Taylor shows in the documentation it would become clear how to do it.

mozew's avatar
Level 6

@JLRDW - Hey

You do not have a job or a life? That day and night you sat down, To the forum

1 like
jlrdw's avatar

@IRANKHOSRAVI - I am semi retired, do small business apps now.

Had rewarding career at a logistics company in java, servlets, jsp, and ejb.

Prior in late 1980's I started out in dbase 3. No windows or forums back then. No COPY AND PASTE code, put something together and hope it works.

No back then you learned the code and hand wrote every line. You used the manual and buy a couple of other good books on the language.

In between the two I wrote CNC routines at a company, cutting machines, tube bending machines, etc.

I had to know the analytic geometry I had in College to do that work.

I did not just "cut and paste".

When you realize it takes many months to "learn" this stuff, you will finally start learning by working examples.

I mean you need to type out all code, no cut and paste.

mozew's avatar
Level 6

I send complete my codes.

Route::get('/code', 'HomeController@code')->name('code');
Route::post('/send', 'HomeController@send')->name('send');

HomeController.php

public function code()
{
    return view('Home.send');
}

public function send(Request $request)
{
    $code = $request->code;
//$mobile = $_GET($request->mobile);
    $mobile = $request->session()->get('mobile');
    $user = User::whereCode($request->code)
        ->whereMobile($request->mobile)
        ->firstOrFail();
    //$user = User::whereCode($code)->whereMobile($mobile)->first();
    if($user){
        $user->verification_code = 1;
        $user->save();
        alert()->success('ok');
        return redirect()->back();
    } else {
        alert()->error('errror');
        return redirect()->back();
    }
}

I tried in hours but I did not successful and did not solve my problem.

Snapey's avatar
    $user = User::whereCode($request->code)
        ->whereMobile($mobile)
        ->firstOrFail();
Snapey's avatar

debug it man

get some skills, track down your problems

jlrdw's avatar

What service are you using for the SMS. Their docs should explain the "how to send".

I would start right at their docs and practice it.

Please or to participate in this conversation.