Giri
Giri

Reputation: 4909

Pass values between pages

I have a page called connect.php

This page connects with twitter and gets the values using OAuth. So this page contains values like this:

$id = 1;
$provider = 'twitter';
$name = 'Tom';

Now I have another page called email.php

This page has a form where a user can enter his email address. Now I would like to pass the values from connect.php to email.php.

Once the email is entered by the user, I would like to insert that data into my database. Can someone point me in the right direction by giving some resources?

Upvotes: 0

Views: 982

Answers (1)

Egor Smirnov
Egor Smirnov

Reputation: 603

You could use PHP sessions - http://php.net/manual/en/session.examples.basic.php.

For your needs you could do something like this.

In connect.php:

session_start();

$_SESSION['id'] = 1;
$_SESSION['provider'] = 'twitter';
$_SESSION['name'] = 'Tom';

In email.php:

session_start();

if(isset($_SESSION['id']))
{
    echo $_SESSION['id']; // echoes 1

    // do something
}

if(isset($_SESSION['provider']))
{
    echo $_SESSION['provider']; // echoes twitter

    // do something
}

if(isset($_SESSION['name']))
{
    echo $_SESSION['name']; // echoes name

    // do something
}

Upvotes: 3

Related Questions