Fenhopi Posted December 15, 2010 Share Posted December 15, 2010 Hi, I have a script that creates a frame. The script shows a page of my choosing. However, somehow I need to transfer some values like username from one page, to the page that is opened in the frame. To call the frame I use like this: <a href="postback.php" id="start">TEST </a> But the only way I know to transfer values between pages is with forms and $_POST. So I have this form: <form method="post" action="postback.php"> <input type="hidden" name="postbackto" value="<? echo $friendshares['byuser']; ?>"> <input type="hidden" name="postbackfrom" value="<? echo $friendshares['person']; ?>"> <INPUT NAME="post" TYPE="submit" class="submit" id="start" value="That's nice" ALT="like"> </form> So what I'm trying to do is that when I click the link, the form is submitted, the frame opens the postback.php and I can view the info from the form. All help is appreciated! Link to comment https://forums.phpfreaks.com/topic/221762-need-some-help-with-a-form-and-a-link/ Share on other sites More sharing options...
solon Posted December 15, 2010 Share Posted December 15, 2010 try this <a href = 'postback.php?postbackto=<?php echo $friendshares['byuser']; ?>&postbackfrom=<?php echo $friendshares['person']; ?>'>TEST</a> and then instead of using $_POST['postbackto'] etc use $_GET['postbackto] Link to comment https://forums.phpfreaks.com/topic/221762-need-some-help-with-a-form-and-a-link/#findComment-1147682 Share on other sites More sharing options...
Fenhopi Posted December 15, 2010 Author Share Posted December 15, 2010 Thanks, man. It did what I tried doing but it didn't work out. Because the frame opens over the window I'm in, so what happens is that i click the link, it starts opening the frame, then I get redirected to postback, and I want to stay on the page I am and just retrieve it through the frame. Any idea how to do this? Link to comment https://forums.phpfreaks.com/topic/221762-need-some-help-with-a-form-and-a-link/#findComment-1147688 Share on other sites More sharing options...
litebearer Posted December 15, 2010 Share Posted December 15, 2010 I like Solon's idea. As an added option, might consider a div rather than a frame and sessions to pass the variables Some psuedo code to ponder... $_SESSION['byuser'] =$friendshares['byuser']; $_SESSION['person'] = $friendshares['person']; ?> <a href="postback.php">some text</a> <?PHP if(!isset($_SESSION['byuser']) OR !isset($_SESSION['person'])) { echo an empty div }else{ echo a div with the content you want } Link to comment https://forums.phpfreaks.com/topic/221762-need-some-help-with-a-form-and-a-link/#findComment-1147689 Share on other sites More sharing options...
solon Posted December 15, 2010 Share Posted December 15, 2010 Actually i believe that litebearer's idea is the one to go with based on what you said in your last post. since it opens in a frame by setting the variable into a session variable it should work Link to comment https://forums.phpfreaks.com/topic/221762-need-some-help-with-a-form-and-a-link/#findComment-1147701 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.