Corentin Branquet
Corentin Branquet

Reputation: 1576

Get value in URL PHP

When I submit a form with wrong id's, the url is set like this :

url-test.com/connexion/?login-failed

I want to trigger login-failed to make conditions.

Here's my code, but it does not work

$login_failed = $_GET['login-failed'];

if($login_failed) {
    $error = 'Oups failed';
}

//My form
<?php wp_login_form(); ?>
<p><?php if(isset($error)) {echo $error;} ?></p>

Thanks for your help !

Upvotes: 0

Views: 40

Answers (2)

Kristian Vitozev
Kristian Vitozev

Reputation: 5971

Your code isn't working, because you're store the value of $_GET['login-failed], but actually there's no value. If you change ?login-failed to ?login-failed=1, it should works.

Otherwise, you should check if variable isset, e.g:

$login_failed = isset( $_GET['login-failed'] ) ? true : false;

Upvotes: 0

Kristiyan
Kristiyan

Reputation: 1663

if(isset($login_failed)) {
    $error = 'Oups failed';
}

You have to check that it's isset.

Upvotes: 3

Related Questions