1

I have an index.php page. The user just connects to the page has a form to login. Once logged in, always display on the same page "Welcome User234, you are logged in. Logout?"

<?php if(isset($_SESSION['user_info']) && is_array($_SESSION['user_info'])) { ?>

    <form id="login-form" class="login-form" name="form1">

        <div id="form-content">
            <div class="welcome">
                <?php echo $_SESSION['user_info']['name']  ?>, you are logged in. 
                <br /><br />
                <?php echo $_SESSION['user_info']['content']  ?>
                <br /><br />
                <a href="index.php?ac=logout" style="color:#3ec038">Logout</a>
            </div>  
        </div>

    </form>

You can see here: http://demo.phpjabbers.com/freescripts/php-user-login/index.php (email: demo1@demo.com, password: pass)

Okay, now I want add my table (http://vulpinelab.online/TabellaExcel/) after the login of the User (each user will see a different table, for example user1 can view only /TabellaExcel, user2 can view only /TabellaExcel2..)

Is there a method to insert the table file in the index.php?

Or there is a method to make the page /TabellaExcel protected by the previous login for each user?

What is the best method and how canI do it?

Marco Bagiacchi
  • 334
  • 2
  • 20
  • you could check for the username and conditionally output your table or if you have roles assigned to the users then you could test for the role and then output the table. Take a look at https://stackoverflow.com/questions/12032271/conditional-embed-html-between-php-code-blocks to learn about conditionally output html from php – Gaurav Singh Faujdar Dec 09 '17 at 13:22
  • You could atleast comment or rate the answer if it was of any help. –  Dec 10 '17 at 05:59

1 Answers1

1

You can make a tableID session variable which is extracted at the time of login from the database for each registered user in an auto_increment manner or however you prefer. According to that unique id variable, you can add the view of different tables for different users.

Suppose, the tableID for user1 is '1', then he will see "/TabellaExcel1" or whatever and for user2 with tableID '2', he can view "/TabellaExcel".$_SESSION['tableID'] (which is 2) thus /TabellaExcel2.You can make use of this method and remember that it isn't necessary to use alternate integers as tableID, for protection they should be unique but random.