KingLouie
KingLouie

Reputation: 451

Pass a variable value from one php page to another

I'm trying to send the value of this php get_field variable from a wordpress Archive page.

get_field('supplier_email_address', 'product_brand_' . $term->term_id );

to another sendmessage.php page which is never accessed other than with the of JS to send a form. The variable I need filled is called:

$sendto="value";

How can I achieve this?

EDIT: Apparently this requires more information.

Upvotes: 2

Views: 27588

Answers (2)

Nambi
Nambi

Reputation: 12042

Use session variables.

First of all every page you want to use sessions on needs to have the function session_start(); declared at the top of every page. You then can use the session superglobal to store things.

Pg1.php:
    <?php
    session_start();
    $_SESSION['variable_name'] = 'string';
    ?>

Pg2.php:
    <?php
    session_start();
    echo $_SESSION['variable_name'];
    ?>
Pg2.php will show: some string

Upvotes: 6

ChunkyBaconPlz
ChunkyBaconPlz

Reputation: 580

Either POST your value so your second page can retrieve it in the $_POST array, or include it in the URL path so your second page can $_GET it.

Without more info, we can't really help you any more than that.

Upvotes: 1

Related Questions