1
<?php
session_start();

if (isset($_POST["user_name"]) && isset($_POST["user_pwd"])) {
    include"php/connect_to_mysql.php";
    $user_name = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["user_name"]);
    $user_pwd = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["user_pwd"]);

    $sql = "SELECT * FROM user_ac WHERE user='$user_name' OR email='$user_name' AND pwd='$user_pwd' LIMIT 1";
    $result = mysqli_query($myConnection, $sql);

    if (mysqli_num_rows($result) > 0) {
        echo "Successfully Logged In";
        header("location: login.html?abc=234");
    } else {

    }
} else {

}    

In this code, inside the second if statement, echo is not displaying anything, but the header function executes correctly.

Please help, thanks.

0

2 Answers 2

3

header function redirect you to new page, so your echo will appear in your current page but your code by this line:

header("location: login.html?abc=234");

will redirect you to new page.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your response. I also tried redirecting to same page but no successs
After removing the redirection line it worked. Thanks again
1

You cannot see the echo because you are going to another page.

As test, remove the header("location: login.html?abc=234"); and you will see the echo.

3 Comments

Thanks for your response. I also tried redirecting to same page but no successs
If you redirect to any page you won't see the echo
After removing the redirection line it worked. Thanks again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.