Felipe Souza Felipe Souza - 5 months ago 8
PHP Question

How to personalize info on a page?

Using PHP.

So I have a login system in place and a database set up with information about the users. Now let's say I want to link the user to a page after login and that page will contain his info. What is the most common way of doing this? Do I echo the whole HTML from a PHP file, or should I make an HTML page and alter it with AJAX somehow? Thanks in advance.

Answer

PHP is used within html. You can create the .php file and have raw html in there. Ex:

  <?php
      session_start(); //Start user session to access $_SESSION variable
      echo 'Hello '.$_SESSION['username'].'.'; //If you had a username variable
  ?>
  <div class="html-class">
     This is raw html.
  </div>
  <div>
   <?php echo 'This is content rendered by PHP'; ?>
  </div>

As far as personalizing pages for users, look into sessions.

Comments