0

After user is registered he is transferred to page

header('location: ' . URLROOT . '/users/login?success=registration');

And i want to display message on view /users/login by grabbing url ?success=registration

<?php

if(isset($_GET['success']) && $_GET['success'] == 'registration'){
    echo ' <h3 style="color: green;">Registration successful</h3>';
} else {
    echo '';
}

I am using handmade MVC framework so I can't refer to /user/login.php it needs to be /user/login because first one is controller and the second is controllers action.

I have two .htaccess files first one is located outside

enter image description here

And the second one located in public folder

enter image description here

NikolaJov
  • 37
  • 1
  • 6
  • 2
    Have you tried `var_dump($_GET)` to see if you get anything at all? Are you using any rewrite rules? If yes, do they pass along the query string? (for mod_rewrite in Apache, the rules should have the `QSA`-flag). Do you see the query param in the URL after the redirect? – M. Eriksson Oct 05 '20 at 14:29
  • Yes i've tried var_dump and it gives me... array(1) { ["url"]=> string(11) "users/login" } ...so apparently it's not reading my ?success=registration at all...Yes i see query param after redirect – NikolaJov Oct 05 '20 at 14:35
  • Are you using Apache? If yes, post your htaccess – M. Eriksson Oct 05 '20 at 14:41
  • At the end of your rules, change `[L]` to `[L,QSA]` and try again. This is from the apache [manual about rewrite flags](https://httpd.apache.org/docs/current/rewrite/flags.html): _"When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined."_ – M. Eriksson Oct 05 '20 at 14:50
  • @MagnusEriksson Thank you [ L,QSA ] was the solution – NikolaJov Oct 05 '20 at 18:20

0 Answers0