954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Order in which it executes in php

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

Phillamon
Junior Poster in Training
65 posts since Oct 2010
Reputation Points: 36
Solved Threads: 5
 

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.

cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

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

Phillamon
Junior Poster in Training
65 posts since Oct 2010
Reputation Points: 36
Solved Threads: 5
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: