0

I have a problem when I try to connect to a personal area. I see a white page after logging in. In my previous host the site worked great. But now I have no idea why I get this problem. I tried to add ob_start it did not help me. I have attached my code below. I would be happy to receive assistance and help in solving this problem.

I tried to add and use php_flag output_buffering on It did not help i get this is error

Warning: session_start(): Cannot start session when headers already sent in /homepages/13/d861839201/htdocs/login/profile/index.php on line 3

Warning: Cannot modify header information - headers already sent by (output started at /homepages/13/d861839201/htdocs/login/profile/index.php:1) in /homepages/13/d861839201/htdocs/login/profile/block.php on line 4

login.php

<?php
ob_start();
session_start();
include('../classes.php');
$mysqli = new database;
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <title>התחברות לאזור אישי</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->  
    <link rel="icon" type="image/png" href="images/icons/favicon.ico"/>
<!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="fonts/iconic/css/material-design-iconic-font.min.css">
<!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="vendor/animate/animate.css">
<!--===============================================================================================-->  
    <link rel="stylesheet" type="text/css" href="vendor/css-hamburgers/hamburgers.min.css">
<!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="vendor/animsition/css/animsition.min.css">
<!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css">
<!--===============================================================================================-->  
    <link rel="stylesheet" type="text/css" href="vendor/daterangepicker/daterangepicker.css">
<!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="css/util.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">
    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css2?family=Raleway:wght@500&display=swap" rel="stylesheet">
<!--===============================================================================================-->
</head>
<body>

            <?php 
            
            if(isset($_POST["submit"])) {
                if(empty($_POST["username"]) || empty($_POST["password"])){
                  echo "<script>alert('Forgot username or password!')</script>";
                }
                $username = $mysqli->con->real_escape_string($_POST["username"]);
                $password = $mysqli->con->real_escape_string($_POST["password"]);
              
                $query = $mysqli->con->query("SELECT * FROM `profile` WHERE `username` = '{$username}'");
                
                $count_row = $query->num_rows;
                if ($count_row == 1) {
                $row = $query->fetch_assoc();
                $password_hash = $row['password'];
                
               if(password_verify($password, $password_hash)){
                $_SESSION['id'] = $row['id'];
                $_SESSION['username'] = $row['username'];
                $_SESSION['email'] = $row['email'];
                $_SESSION['group'] = $row['group'];
                header ("Location: profile/index.php");
                 return true;
               }
              
                  else{
                    echo "<script>alert('Username or password incorrect!')</script>";
                  }
                }
                }
            
            
             ?>

    <div class="limiter">
        <div class="container-login100" style="background-image: url('images/bg-01.jpg');">
            <div class="wrap-login100">
            <form action="" method="post">
                    <span class="login100-form-logo">
                    <img class="img_login" src="images/logo.png" alt="Avatar">
                    </span>

                    <span class="login100-form-title p-b-34 p-t-27">
                        התחברות - לאזור אישי
                    </span>
                    
                    <div class="wrap-input100 validate-input" data-validate = "Enter username">
                        <input class="input100" type="text" name="username" placeholder="Username">
                        <span class="focus-input100" data-placeholder="&#xf207;"></span>
                    </div>

                    <div class="wrap-input100 validate-input" data-validate="Enter password">
                        <input class="input100" type="password" name="password" placeholder="Password">
                        <span class="focus-input100" data-placeholder="&#xf191;"></span>
                    </div>

                    <div class="contact100-form-checkbox">
                        <input class="input-checkbox100" id="ckb1" type="checkbox" name="remember-me">
                        <label class="label-checkbox100" for="ckb1">
                            Remember me
                        </label>
                    </div>

                    <div class="container-login100-form-btn">
                        <button name="submit" id="submit" type="submit" class="login100-form-btn">
                            התחברות
                        </button>
                    </div>
                 
                    <div class="text-center p-t-90">
                        <a class="txt1" href="#">
                            שכחתי סיסמא.
                        </a>
                    </div>
                </form>
                </form>
            </div>
        </div>
    </div>
    



    <div id="dropDownSelect1"></div>
    
<!--===============================================================================================-->
    <script src="vendor/jquery/jquery-3.2.1.min.js"></script>
<!--===============================================================================================-->
    <script src="vendor/animsition/js/animsition.min.js"></script>
<!--===============================================================================================-->
    <script src="vendor/bootstrap/js/popper.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<!--===============================================================================================-->
    <script src="vendor/select2/select2.min.js"></script>
<!--===============================================================================================-->
    <script src="vendor/daterangepicker/moment.min.js"></script>
    <script src="vendor/daterangepicker/daterangepicker.js"></script>
<!--===============================================================================================-->
    <script src="vendor/countdowntime/countdowntime.js"></script>
<!--===============================================================================================-->
    <script src="js/main.js"></script>

</body>
</html>

index.php after you login

<?php
session_start();
include ('../../classes.php');
include ('block.php');
$mysqli = new database;
       
        $query_training = $mysqli->training(); // שולף את כל הנתונים של ההכשרות
        $id = $_SESSION['id'];
        $query_profile = $mysqli->con->query("SELECT * FROM `profile` where id = '{$id}'");
        $result = $query_profile->fetch_assoc();
        $query_role = $mysqli->Role();
        $fetch_role = $query_role->fetch_assoc();

?>

<!doctype html>
<html lang="he">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="styles.css">
    <link rel="shortcut icon" href="../favicon.ico">
   <!-- GOOGLE - FONTS CSS -->
   <link rel="preconnect" href="https://fonts.gstatic.com">
   <link href="https://fonts.googleapis.com/css2?family=Arimo&display=swap" rel="stylesheet"> 



    <title>Profile - אזור אישי</title>
  </head>
  <body>
       <!-- תפריט של  הפאנל -->
        <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <a class="navbar-brand" href="#">
      <img src="../images/logo.png" alt="" width="100" height="100">
        </a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
                aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <?php include('menu.php');?>
            </div>

        </nav>
         <!-- תפריט של  הפאנל -->
    
        <section id='info'>
           
        <!-- Tab panes -->
        <div class="tab-content mb-5 mt-3">
        <h2 class="text-center"><?php echo $_SESSION['username'];?></h2>
        <hr>
            <div id="info" class="container tab-pane active in"><br>

                <div class="row my-profile">
                    <div class="col-md-6 col-12">
                        <div class="card">
                            <h5 class="card-header">פרטים אישיים</h5>
                            <div class="card-body" style="padding: 0">

                                <ul style="padding: 0" class="list-group list-group-flush">
                                    <li class="list-group-item"><i
                                            class="fas fa-user-alt text-muted"></i><span> שם מלא: </span><span
                                            class="float-left ml-4"> <?php echo $result['name']; ?> </span></li>
                                                                    
                    
                          <li class="list-group-item"><i class="fas fa-clock text-muted"></i><span> גיל: </span><span class="float-left ml-4"><?php echo $result['age']; ?></span></li>

                                </ul>
                            </div>
                        </div>
                    </div>


                    <div class="col-md-6 col-12">
                        <div class="card">
                            <h5 class="card-header">פרטים כלליים</h5>
                            <div class="card-body" style="padding: 0">

                                <ul style="padding: 0" class="list-group list-group-flush">
                                                                            <li class="list-group-item"><i class="fas fa-at text-muted"></i><span> דואר אלקטרוני: </span><span class="float-left ml-4"><?php echo $result['email']; ?></span></li>
                                        <li class="list-group-item"><i class="fab fa-discord text-muted"></i><span> דיסקורד: </span><span class="float-left ml-4"><?php echo $result['discord']; ?></span></li>
                                    


                                    <li class="list-group-item"><i class="fas fa-id-card text-muted"></i><span> תפקידים: </span><span class="float-left ml-4"><?php echo $fetch_role['name_group']; ?></span></li>
                                </ul>

                            </div>
                        </div>
                    </div>

                    <div class="col-12 mt-5">
                        <div class="row">
                            <div class="col-12 col-md-6">
                                <div class="card">
                                    <h5 class="card-header">הסמכות</h5>
                                    <div class="card-body" style="padding: 0">
                                        <div class="card-body" style="padding: 0">
                                            <ul style="padding: 0" class="list-group list-group-flush">
                                               <?php while($result = $query_training->fetch_assoc()){
                                                 $training = $result['training_name'];
                                                  echo "<li class='list-group-item'>$training</li>";
                                                    } ?>
                                                                                                    
                                                         </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        
           

            <div id="statistics" class="container tab-pane mt-3 ">
                <div class="row my-profile mt-5">
                    <div class="col-12">
                        <span id="profile-statistics">
                            <div class="loader mx-auto mt-5"></div>
                        </span>
                    </div>
                </div>
            </div>

                            <div id='equipment' class='container tab-pane  in'>
                    <div class='row my-profile'>
                        <div class='col-12'>
                            <span id="profile-equipment">
                                <div class="loader mx-auto mt-5"></div>
                            </span>
                        </div>
                    </div>
                </div>
                    </div>
    </div>
        </div>
        </section>


    <!-- Scripts -->
    <script src="https://kit.fontawesome.com/c0d1afb774.js" crossorigin="anonymous"></script>
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>

  </body>
</html>
Dan
  • 1
  • 1
  • So did you check the logs? Were there any clues in there – RiggsFolly Feb 18 '21 at 09:42
  • 1
    `$query_training = $mysqli->training();` What is `$mysqli->training();` – RiggsFolly Feb 18 '21 at 09:43
  • I have no logs. @RiggsFolly – Dan Feb 18 '21 at 09:45
  • It is oop. I think the problem is in the session something strange. @RiggsFolly – Dan Feb 18 '21 at 09:46
  • I see its an object method being called mate. But I have never seen a `training` method on a MySQLI object – RiggsFolly Feb 18 '21 at 09:49
  • It's just pulling data from my classes. But that's not the problem. I have the lock of the personal area and when I delete it. He enters a personal area but he does not get the details of the user it is something in a session. @RiggsFolly – Dan Feb 18 '21 at 09:51
  • And what do you mean by _connect to a personal area_ What is one of those – RiggsFolly Feb 18 '21 at 09:52
  • Your script is open to [SQL Injection Attack](http://stackoverflow.com/questions/60174). Even [if you are escaping inputs, its not safe!](http://stackoverflow.com/questions/5741187) You should alway use [prepared parameterized statements](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) in either the `MYSQLI_` or `PDO` API's instead of concatenating user provided values into the query. Never trust ANY user input! – RiggsFolly Feb 18 '21 at 09:53
  • I did not understand the question. I just log in and see a blank page. @RiggsFolly – Dan Feb 18 '21 at 09:54
  • You must have logs, apache/php/mysql – RiggsFolly Feb 18 '21 at 09:54
  • I have a sftp.log host. This file?@RiggsFolly – Dan Feb 18 '21 at 09:56
  • To get errors out of PHP even in a LIVE environment add these 4 lines to the top of any `MYSQLI_` based script you want to debug `ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);`. This will force any `MYSQLI_` errors to generate an Exception that you can see on the browser as well as normal PHP errors. – RiggsFolly Feb 18 '21 at 09:58
  • Hey, I have attached the error I get @RiggsFolly – Dan Feb 18 '21 at 10:01
  • @RiggsFolly you can help me please? – Dan Feb 18 '21 at 10:30
  • Read the question and Answer in the duplicate Q&A, you have one of those issues – RiggsFolly Feb 18 '21 at 10:38
  • I ran php_flag output_buffering on It did not help. I do not know why my question was closed to me. @RiggsFolly – Dan Feb 18 '21 at 10:39
  • The question was close because there is a valid answer (The Duplicate), read all the answers and check your code for the mentioned issue. **It will be one of those mentioned** – RiggsFolly Feb 18 '21 at 10:43
  • I checked everything that was listed there of course. It did not solve my problem unfortunately. @RiggsFolly – Dan Feb 18 '21 at 10:46
  • Then I cannot help either. – RiggsFolly Feb 18 '21 at 10:56

0 Answers0