dimple Posted October 5, 2009 Share Posted October 5, 2009 Hi, Can any one one tell me how to pass a text box (Session variable) value from one form to another using submit button. I tried it , but there is a problem like i have to press enter first then the value pass on nsession then i can go to next page but i dnt want these type of problems in my project. Kindly help me here or mail me to gr8.php@gmail.com Thanx. Quote Link to comment https://forums.phpfreaks.com/topic/176550-how-to-pass-value-from-one-page-to-other-inphp/ Share on other sites More sharing options...
RichardRotterdam Posted October 5, 2009 Share Posted October 5, 2009 If it's a session var then use $_SESSION If you just want to pass a form value use $_POST or $_GET depending on the method Quote Link to comment https://forums.phpfreaks.com/topic/176550-how-to-pass-value-from-one-page-to-other-inphp/#findComment-930662 Share on other sites More sharing options...
cags Posted October 5, 2009 Share Posted October 5, 2009 You seem to be confused between concepts here. Passing a variable between forms using the submit button is all to do with using the $_POST and $_GET superglobal arrays. $_SESSIONS is another superglobal array which is generally used to maintain a value during that users visit to a site, regardless of the page they are on. Page1.php <form action ="Page2.php" method="post"> <input type="text" name="username" /> <input type="submit" value="Send" /> </form> Page2.php <form action ="Page2.php" method="post"> <input type="text" name="username" value="<?php echo $_POST['username']; ?> /> <input type="submit" value="Send" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/176550-how-to-pass-value-from-one-page-to-other-inphp/#findComment-930665 Share on other sites More sharing options...
dimple Posted October 5, 2009 Author Share Posted October 5, 2009 Ohhhhh No , Actually i tried that all but its not work properly. Its a session variable & i need it on further forms so how to i pass session value to other forms without hit enter key. Quote Link to comment https://forums.phpfreaks.com/topic/176550-how-to-pass-value-from-one-page-to-other-inphp/#findComment-930669 Share on other sites More sharing options...
daneth1712 Posted October 5, 2009 Share Posted October 5, 2009 to get to the next page, a button of some sort needs to be pressed... I assume.... if thats the case, then the best way is to POST the info to the next page. you can store the info in a session like below; session_start(); $_SESSION['textarea']= ['textarea']; header( "Location: nextpage.php" ); then on the top of the next page.... <?php //start the session session_start(); //check to make sure the session variable is registered if(isset($_SESSION['textarea'])){ $text=$_SESSION['textarea']; } else{ //the session variable isn't registered, send them to the error page header( "Location: errorpage.php" ); } ?> this saves your 'textarea' info into a variable called $text Quote Link to comment https://forums.phpfreaks.com/topic/176550-how-to-pass-value-from-one-page-to-other-inphp/#findComment-930672 Share on other sites More sharing options...
dimple Posted October 5, 2009 Author Share Posted October 5, 2009 I m sure session variable is registered bcz after press the enter button it take its value then i click on next link for next page & there i use session variable in my query to filter data. Its mean the session is registered but the problem is how to put value in session without press enter key. Quote Link to comment https://forums.phpfreaks.com/topic/176550-how-to-pass-value-from-one-page-to-other-inphp/#findComment-930681 Share on other sites More sharing options...
RichardRotterdam Posted October 5, 2009 Share Posted October 5, 2009 In order to put a form value inside a session the form has to be submitted. Either that or use ajax Quote Link to comment https://forums.phpfreaks.com/topic/176550-how-to-pass-value-from-one-page-to-other-inphp/#findComment-930701 Share on other sites More sharing options...
dimple Posted October 6, 2009 Author Share Posted October 6, 2009 I m using ajax autocomplete in textbox which value is stored in session after submission. Quote Link to comment https://forums.phpfreaks.com/topic/176550-how-to-pass-value-from-one-page-to-other-inphp/#findComment-931287 Share on other sites More sharing options...
dimple Posted October 7, 2009 Author Share Posted October 7, 2009 hey no one has idea about dat Quote Link to comment https://forums.phpfreaks.com/topic/176550-how-to-pass-value-from-one-page-to-other-inphp/#findComment-932173 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.