grungefreak Posted April 4, 2008 Share Posted April 4, 2008 Hi guys, I want to get familiar with using the GET method on my php pages. I want to just get one working and figure the logic from there. Can somebody just give me a piece of code that will do the following: I have foo.php and bar.php files. I want to set a variable in foo.php and grab it in bar.php using $_GET['var']. Then echo it to the screen. I realise this is fairly simple but I always work with $_POST and wanna try $_GET. Thanks in advance. GF Link to comment https://forums.phpfreaks.com/topic/99600-solved-using-get/ Share on other sites More sharing options...
p2grace Posted April 4, 2008 Share Posted April 4, 2008 This is how it works: <?php // foo.php echo "<a href='bar.php?num1=5&num2=3'>bar.php</a>"; // bar.php if(isset($_GET['num1']) && isset($_GET['num2'])){ $num1 = $_GET['num1']; $num2 = $_GET['num2']; $total = $num1 + $num2; echo "$num1 + $num2 = $total"; } ?> Link to comment https://forums.phpfreaks.com/topic/99600-solved-using-get/#findComment-509568 Share on other sites More sharing options...
grungefreak Posted April 5, 2008 Author Share Posted April 5, 2008 This is how it works: <?php // foo.php echo "<a href='bar.php?num1=5&num2=3'>bar.php</a>"; // bar.php if(isset($_GET['num1']) && isset($_GET['num2'])){ $num1 = $_GET['num1']; $num2 = $_GET['num2']; $total = $num1 + $num2; echo "$num1 + $num2 = $total"; } ?> Excellent! Thank you so much. GF Link to comment https://forums.phpfreaks.com/topic/99600-solved-using-get/#findComment-510233 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.