0

Just something small and I'm not sure how to do it. What I want to do when the user cannot be found in my DB then it should:

1. Print out -I wanted to use a pop-up to inform the user that he has entered incorrect log in details. Which I echo'ed with Javascript

2. Then after the popup the user should return to the Login.html. Because currently it just executes the header function straight without acknowledging the echo


Below: Login.php

if(mysql_num_rows($result)){
                                $user = mysql_fetch_assoc($result);
                                echo '<h1>Welcome, ';
                                    echo $user['Name'];
                                echo '</h1>';  
                            }else{
                               echo "<script type='text/javascript'>alert('Please enter your correct account details');</script>";
                               header("location:login.html?msg=$msg");
                            }

I'm a bit new with the whole php thing-still learning! :)

Any help will be appreciated!

Thanks

2
Contributors
2
Replies
5
Views
5 Years
Discussion Span
Last Post by Phillamon
1

Try the following:

if(mysql_num_rows($result)>0){
    $user = mysql_fetch_assoc($result);
    echo '<h1>Welcome, ';
    echo $user['Name'];
    echo '</h1>';  
}else{
    header("location:login.html?msg=$msg");
}

And on login.html you will need to place the javascript message instead of the page with the header redirect.

Edited by cwarn23: n/a

1

Thanks for the reply! I tried an alternative with just the

header("location:Not_Registered.html?msg=$msg");

And then from there you can navigate back to the login.html

Votes + Comments
Good response. Love the easy answers :)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.