Getting Information From One Page To Another

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Darksevear
Forum Newbie
Posts: 11
Joined: Sat May 13, 2006 10:38 pm

Getting Information From One Page To Another

Post by Darksevear »

I have read many tutorials on POST and GET. But i cant seem to get a variable from one page to another can someone please advise how to do this.

I just need to get a variable from a.php to b.php, a.php has a link to b.php

- Cheers, Daniel
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Code: Select all

<?php
// This is a.php
echo '<a href="b.php?somevar=thisvalue">Go to page b</a>';
?>

Code: Select all

<?php
// this is b.php
if (isset($_GET['somevar']))
{
    $myvar = $_GET['somevar'];
    // validate the var value here then echo it out
    echo $myvar;
}
?>
Post Reply