How to Redirect Back to a Page I'M Currently On

How do I redirect back to a page I'm currently on?

redirect_to :back worked for me but I want to see if this was the right choice
http://api.rubyonrails.org/files/actionpack/lib/action_controller/metal/redirecting_rb.html

Redirect back to own webpage after visiting another website

Make use of cURL

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://sms.xyz.com/uname=abc&pass=xyz&phone=1234567890&msg=hello");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // For HTTPS
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // For HTTPS
curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); // Returns 200 if everything went well
if($statusCode==200)
{
echo "<script>alert('SMS Sent');</script>";
echo "<script>document.location.href='welcome.html'</script>"; //Redirecting back after successfully sent SMS
}
else
{
echo "<script>alert('SMS Sending Failed.');</script>";
}

curl_close($ch);

How to redirect back to a link after logged in

If you use "is_navigational_format?" like below,

def storable_location?
request.get? && is_navigational_format? && !devise_controller? && !request.xhr?
end

and if you have a link with id like "/comments/anytask.123", then "is_navigational_format?" can not judge ".123" as a format.

So I needed to add below routes and solved!!!

get 'comments/anytask.:id' => 'comments#anytask', as: :comments_anytask

Laravel 4 - Redirect back to the same page where the request comes from

Yes this is available:

return Redirect::back()->with('message','Operation Successful !');

But since this is a redirected request, you have to access the message by using:

echo Session::get('message');

How to redirect back after logged-in to previous page after logged out on that page in Laravel 5

U CAN USE THIS CODE

       return redirect()->back();

or

u can use route and in ur route u need to configure and in controller u can put the below code
// this is ur route

Route::get('/dashboard',[
'uses' => 'PostController@dashboard',
'as' => 'dashboard',
'middleware' => 'auth'
]);

//put this in ur controller
return redirect()->route('dashboard');

Redirect url to previous page in laravel

Thank You for answers.
I've got it now.

set the hidden variable in blade to get previous page url using

{{  Form::hidden('url',URL::previous())  }}

after that get it by $request->input('url'); in controller,Then redirect it.

return redirect($url)->with('success', 'Data saved successfully!');


Related Topics



Leave a reply



Submit