ted_chou12 Posted December 15, 2006 Share Posted December 15, 2006 what i want to do is to pass a string from one page to another (just like my subject title)what it means is this:first php page:<?php$string = "information"?><a href="page2.php">click here</a>and then when the visitor clicks the hyperlink, he/she is transferred to the second page, however, i also want the string to be transferred as well so you can echo it on the second page.<?phpecho $string?>However, I dont wish to write nor create any text files, is there any suggestions?Thankyou :D Link to comment https://forums.phpfreaks.com/topic/30788-solved-pass-string-from-one-page-to-the-other/ Share on other sites More sharing options...
craygo Posted December 15, 2006 Share Posted December 15, 2006 just add it to the url[code]<?php$page = "page2.php";?><a href = "page.php?page=<?=$page?>">click here</a>[/code]now you can call the page by [code]<?phpecho $_GET['page'];?>[/code]Ray Link to comment https://forums.phpfreaks.com/topic/30788-solved-pass-string-from-one-page-to-the-other/#findComment-141929 Share on other sites More sharing options...
redbullmarky Posted December 15, 2006 Share Posted December 15, 2006 $_SESSIONS are your friend here if you don't want to reveal the data. $_GET (as suggested by craygo) are useful otherwise. for example:page 1 has this in it:[code]<?phpsession_start();$_SESSION['string'] = 'information';?>[/code]page 2 has this in it:[code]<?phpsession_start();echo $_SESSION['string'];?>[/code] Link to comment https://forums.phpfreaks.com/topic/30788-solved-pass-string-from-one-page-to-the-other/#findComment-141930 Share on other sites More sharing options...
ted_chou12 Posted December 15, 2006 Author Share Posted December 15, 2006 oh, but if sessions are not destoryed, how long will they stay for? permenantly?(btw, thanks for [color=red]craygo[/color] and [color=red]redbullmarky[/color]) Link to comment https://forums.phpfreaks.com/topic/30788-solved-pass-string-from-one-page-to-the-other/#findComment-141932 Share on other sites More sharing options...
complex05 Posted December 15, 2006 Share Posted December 15, 2006 sessions can last up to one hour, however they are renewed each time you perform a function with them. Link to comment https://forums.phpfreaks.com/topic/30788-solved-pass-string-from-one-page-to-the-other/#findComment-141941 Share on other sites More sharing options...
ted_chou12 Posted December 15, 2006 Author Share Posted December 15, 2006 okay!thankyou Link to comment https://forums.phpfreaks.com/topic/30788-solved-pass-string-from-one-page-to-the-other/#findComment-141944 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.