Skip to main content
February 26, 2012
Answered

session_start();

  • February 26, 2012
  • 1 reply
  • 618 views

I want to send information from one page to another using the session_start();.

Lets say that page1.php has a session above the <!DOCTYPE HTML> doctype.

<?php

  session_start();

  $_SESSION['mylink'] = $row_mymeeting['congremtid'];

?>

And in my body tag the following shows...

<body>

<a href="page2.php">Here we go</a>

</body>

When I look at page1.php in my browser I get an error

Notice:  Undefined variable: row_mymeeting in /Applications/MAMP/htdocs/phptest/www/index.php on line 5

However if I put $_SESSION['mylink'] = "Hello, Welcome to Adobe!"; when I click on the link to the page2.php page it shows.

And on  page2.php I want it to echo what ever the $row_mymeeting['congremtid'] has in my databse.

One page 2 I have...

<?php

  session_start();

?>

<?php

echo $_SESSION['mylink'];

?>

But I get a blank.

How can I make my $_SESSION['mylink'] = $row_mymeeting['congremtid']; echo in my second page, what am I missing?

Thank you.

Regards,

AdonaiEchad

This topic has been closed for replies.
Correct answer osgood_

Have you got a recordset on the page which SELECTS 'congremtid' from the database? AND is the line $_SESSION['mylink'] = $row_mymeeting['congremtid']; AFTER the sql query? If you haven't or the line is NOT AFTER the sql query you will get an error about the Undefine Variable.

1 reply

osgood_Correct answer
Legend
February 27, 2012

Have you got a recordset on the page which SELECTS 'congremtid' from the database? AND is the line $_SESSION['mylink'] = $row_mymeeting['congremtid']; AFTER the sql query? If you haven't or the line is NOT AFTER the sql query you will get an error about the Undefine Variable.

February 27, 2012

Thank you osgood.

That was my issue.

The $_SESSION['mylink'] = $row_mymeeting['congremtid']; was placed before the recordset.  I placed it at the top of the recordset therefore I was getting the error that I posted in this forum.

Again, thank you.

It is amazing that positioning can do a lot.

Regards,

AdonaiEchad