A
A
ART42019-12-16 12:03:14
PHP
ART4, 2019-12-16 12:03:14

How to add a specific block from a specific page?

Good afternoon. There are 2 pages:

  1. /user
  2. /cart

But from these pages you can get to 1 page /order .
How to add a block to the /order page if the person came from the /user page .
Tried doing it like this:
if($_SERVER['HTTP_REFERER'] == "/user"){
             echo "Зашёл с аккаунта";
        } else if ($_SERVER['HTTP_REFERER'] == "/cart") {
            echo "С корзины зашёл";
        } else {
            echo "3 вариант";
        }

Gives always "3 option"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
#
#yamynginx, 2019-12-16
@ART4

Because the full address is stored in - " https://domain.ltd/user "$_SERVER['HTTP_REFERER']

if (strpos($_SERVER['HTTP_REFERER'], '/user')) {
  echo 'Зашёл с аккаунта';
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question