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

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.

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

commented: Good response. Love the easy answers :) +12
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.