dimanche 21 avril 2019

If Else with isset: else part does not work [PHP]

Hello i dont get the $msg shown if my Username and Password is not the correct one.´Here is the php isset Part.

        if(isset($_POST['Submit'])){
    $Username = $_REQUEST['Username'];
    $Password  = $_REQUEST['Password'];
    $tsql = "SELECT * FROM MasterarbeitDB.dbo.Benutzer WHERE Benutzer='$Username' AND Passwort='$Password'";

    $stmt = sqlsrv_query( $conn, $tsql, array(), array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
    if ($stmt) {
    while( $obj = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC)) {
           if($obj['Benutzer'] == $_POST['Username'] && $obj['Passwort'] == $_POST

['Password'])  {



    $_SESSION['valid_user'] = true;
    $_SESSION['Username'] = $Username;
            header("location:ma_Qualianlegen.php?QualiID=".$QualiID."&TestaufstellungID=".$TestaufstellungID."&Bezeichnung=".$Bezeichnung."&StatusID=".$StatusID."");
            exit;
        }else {

            $msg="<span style='color:red'>falsche Login-Date</span>";
        } 
}
}
}

Any help why this happen? thx

Aucun commentaire:

Enregistrer un commentaire