Passing parameters with post to a new page


#1

Hello,
I’m trying to pass parameters from one page to the other.

I built an if statement in the statement I check if a session exists in case it exists I try to redirect the user to a different page.

I have on the new page a “div” that I would like to input a message once the user is redirected.

I am struggling with this code.

The code I have so far is:

 if( isset($_SESSION['name']) || isset($_COOKIE['email'])){

  $Nav_bar_message = 'Eli is king';

  header('location: Home_Page.php?Nav_bar_message');

}

Here is the code on the second page with the div:

<div>

<p><?= $Nav_bar_message ;?> </p>

</div>

Thank you for your help.


#2

That will redirect, but it wont show any messages.

Are you using

session_start()

at the top of those pages?


#3

Thank you for your answer

I actually wanted to

Pas a variable using the url.

I found the following article that helps a lot:

http://www.shodor.org/~kevink/phpTutorial/davida_PassVarByUrl.php


#4

If you want to pass a value via get request (in the url) then you have to have a variable to hold the value.

http://www.example.com/test.php?v=something
test.php

<?php

if(isset($_GET['v'])) {
    echo htmlentities($_GET['v']);
} else {
    echo "Nothing was passed";
}

#5

Thank you,