xrez Posted June 20, 2007 Share Posted June 20, 2007 Hi i am quite new to php and would like to get some help. My problem is that i want to get a value from a textbox in the same php form and pass it to another page. For example i have this: <?php echo "<td><input type=\"text\" name=\"firstName\"></td>"; $aname = $_GET('firstName'); echo "<td><input type=\"button\" name=\"ClickMe\" value=\"Click ME\" style=\"font-size:7pt\" onclick=\"window.addedit.location='newpage.php?&thename='$aname';\"></td>"; ?> so essentially i want to create a variable and assign the value in the textbox to it and pass it to a new page. I have tried $_GET, $_POST and $_REQUEST and all of them dont work. I know you can do this really easily with .net or java, it would be just by saying something like $avar = textbox.value or something like that, but in php it seems a LOT more complicated ... Can someone please help me? Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 20, 2007 Share Posted June 20, 2007 did u use form tag ? I dont see the form action line is there any? show as the little code Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 20, 2007 Share Posted June 20, 2007 If you post the current code to another page the varable firstname should echo on the other page, but if you need to get a varable to another page while using the same page to post within use session's ok. WARNING session_start(); needs to be on all pages that use the session. <?php session_start(); $_SESSION['firstname']=$GET['firstname']; // more code. ?> // the page to display <?php session_start(); echo $firstname; ?> Quote Link to comment Share on other sites More sharing options...
xrez Posted June 20, 2007 Author Share Posted June 20, 2007 is there anyway todo it without sessions? Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 20, 2007 Share Posted June 20, 2007 is this what you mean <input type="text" name="kumagka" value="<?=$GET['your stuff here']?>"> if not pls explain more pls Quote Link to comment Share on other sites More sharing options...
xrez Posted June 20, 2007 Author Share Posted June 20, 2007 can you explain what this part does please: value="<?=$GET['your stuff here']?> Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted June 20, 2007 Share Posted June 20, 2007 In this example someone clicks a link that moves a variable to the next page. The example uses $page, the page id. <?php // Define the variable you want to move to the next page... $page = " DEFINE THIS"; ?> html code... LInk to the next page carrying the variable with it. <a href="fav.php?page=<?php echo $page; ?>"> Code on the next page... <?php // Page ID $page = $_GET['page']; ?> I'm sorta confused on what you want to do. But this is an example of the method of "_GET." That you need to use. Quote Link to comment Share on other sites More sharing options...
xrez Posted June 20, 2007 Author Share Posted June 20, 2007 If you post the current code to another page the varable firstname should echo on the other page, but if you need to get a varable to another page while using the same page to post within use session's ok. WARNING session_start(); needs to be on all pages that use the session. <?php session_start(); $_SESSION['firstname']=$GET['firstname']; // more code. ?> // the page to display <?php session_start(); echo $firstname; ?> I have tried this but it doesnt seem to display the value on the other page Quote Link to comment Share on other sites More sharing options...
xrez Posted June 20, 2007 Author Share Posted June 20, 2007 In this example someone clicks a link that moves a variable to the next page. The example uses $page, the page id. <?php // Define the variable you want to move to the next page... $page = " DEFINE THIS"; ?> html code... LInk to the next page carrying the variable with it. <a href="fav.php?page=<?php echo $page; ?>"> Code on the next page... <?php // Page ID $page = $_GET['page']; ?> This is very close to what i want, but instead of : $page = " DEFINE THIS"; i want $page to get the value from a textbox Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted June 20, 2007 Share Posted June 20, 2007 There is no support with textarea and php. That is what I searched on google and found. YOU MUST use form. That means using _Post instead of _Get. Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 20, 2007 Share Posted June 20, 2007 if u will be dealing with big file you cant use get use post instead or if u think the data wont reach the limitation of the session the use it but its not recommended it slows down your site. I simply cant understand y post is not working explain it plzz??? Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 20, 2007 Share Posted June 20, 2007 sorry my fault there u go. <?php session_start(); $_SESSION['firstname']=$GET['firstname']; // more code. ?> // the page to display <?php session_start(); echo $_SESSION['firstname']; ?> Quote Link to comment Share on other sites More sharing options...
xrez Posted June 20, 2007 Author Share Posted June 20, 2007 if u will be dealing with big file you cant use get use post instead or if u think the data wont reach the limitation of the session the use it but its not recommended it slows down your site. I simply cant understand y post is not working explain it plzz??? Well for one i am not using form tags. All i want todo is get the value from a text field in the same php page and pass that value using javascript to another page. Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted June 20, 2007 Share Posted June 20, 2007 Google it. I just googled this and found out the only way to do what you want to do is by JAVASCRIPT. Check out the tutorials, - they are great. Otherwise, use form tags or session. Quote Link to comment Share on other sites More sharing options...
xrez Posted June 20, 2007 Author Share Posted June 20, 2007 Google it. I just googled this and found out the only way to do what you want to do is by JAVASCRIPT. Check out the tutorials, - they are great. Otherwise, use form tags or session. I did try to google this problem but to no avail. If you could provide some light on this situation that would be great Quote Link to comment 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.