0

Hi,
Please help me to resolve my Script Redirection problem.
Actually i have developing simple crm application php using pdo->prepare. this is working fine in localhost.
but what is my problem means redirection is not working, when i uploaded to server.
for refernce i hereby attached . please help me anyone.

 <?php
    session_start();
    $errmsg_arr = array();
    $errflag = false;
    // configuration
   include("config/db-config.php");
    // new data

    $user = $_POST['uname'];
    $password = $_POST['pword'];

    if($user == '') {
    $errmsg_arr[] = 'You must enter your Username';
    $errflag = true;
    }
    if($password == '') {
    $errmsg_arr[] = 'You must enter your Password';
    $errflag = true;
    }

    // query
    $result = $db->prepare("SELECT * FROM admin WHERE username= ? AND password= ?");
$result->bindParam(1, $user);
$result->bindParam(2, $password);
$result->execute();
   // $rows = $result->fetch(PDO::FETCH_NUM);
    if($row = $result->fetch(PDO::FETCH_ASSOC)) //ftch value as row or array
    {
            $_SESSION["SESS_USERID"] = $row['id'];
            $_SESSION["SESS_FIRSTNAME"] = $row['name'];
            $_SESSION["SESSION_USER_NAME"] = $row['username'];
            header('Location: admin-home.php');
        }
    else{
    $errmsg_arr[] = 'Username and Password are not found';
    $errflag = true;
    }
    if($errflag) {
    $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
    session_write_close();
    header("location: index.php?=Username and Password are not found");
    exit();
    }

    ?>
2
Contributors
3
Replies
23
Views
3 Years
Discussion Span
Last Post by fireburner29
1

Which branch is not working? You have more than one redirect.
Also the last redirect should be urlencoded.

0
 if($row = $result->fetch(PDO::FETCH_ASSOC)) //ftch value as row or array
{
$_SESSION["SESS_USERID"] = $row['id'];
$_SESSION["SESS_FIRSTNAME"] = $row['name'];
$_SESSION["SESSION_USER_NAME"] = $row['username'];
header('Location: admin-home.php');
}

in this part only

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.