Pass the Variable to another page

How can i pass a variable which is in a URL to the next page. See the Code.

      $connection = mysqli_connect('localhost' , 'root' ,'','test');
      $query = "SELECT * FROM categories";
      $select_all_categories = mysqli_query($connection,$query);

      while ($row = mysqli_fetch_assoc($select_all_categories)) {
              $cat_title = $row['cat_title'];

              echo "<div class='list-group'>
                <a href='change_view.php?site=$cat_title' 
          class='list-group-item list-group-item-action' > $cat_title</a>"; 
          //want to pass the $cat_title variable (every time new) to another page.}

In change_view.php just do something like

if(isset($_GET['site'])) {


} else {

    print('Most likely the home page since the get parameter was not set');



This isn’t a full snippet. It’s supposed to give you an idea on what to do.

           $myvariable = 'website';
            $_SESSION['session'] = $myvariable;

i want to store the site value in this session and than want to take the value to another page how is that possible?

You could do something like the following? (I don’t know exactly what you are trying to do?)

$myVariable = (isset($_SESSION['session'])) ? $_SESSION['session'] : NULL;

then I would just put that in your config.php or file that usually goes at the top of every page.

$cat_title is already being passed through the URL so I don’t understand what you are trying to achieve with using session variables.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.