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? Link to comment https://forums.phpfreaks.com/topic/56305-getting-a-value-from-a-textbox-in-the-same-php-form/ 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 Link to comment https://forums.phpfreaks.com/topic/56305-getting-a-value-from-a-textbox-in-the-same-php-form/#findComment-278148 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; ?> Link to comment https://forums.phpfreaks.com/topic/56305-getting-a-value-from-a-textbox-in-the-same-php-form/#findComment-278149 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? Link to comment https://forums.phpfreaks.com/topic/56305-getting-a-value-from-a-textbox-in-the-same-php-form/#findComment-278217 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 Link to comment https://forums.phpfreaks.com/topic/56305-getting-a-value-from-a-textbox-in-the-same-php-form/#findComment-278220 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']?> Link to comment https://forums.phpfreaks.com/topic/56305-getting-a-value-from-a-textbox-in-the-same-php-form/#findComment-278221 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. Link to comment https://forums.phpfreaks.com/topic/56305-getting-a-value-from-a-textbox-in-the-same-php-form/#findComment-278222 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 Link to comment https://forums.phpfreaks.com/topic/56305-getting-a-value-from-a-textbox-in-the-same-php-form/#findComment-278223 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 Link to comment https://forums.phpfreaks.com/topic/56305-getting-a-value-from-a-textbox-in-the-same-php-form/#findComment-278224 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. Link to comment https://forums.phpfreaks.com/topic/56305-getting-a-value-from-a-textbox-in-the-same-php-form/#findComment-278232 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??? Link to comment https://forums.phpfreaks.com/topic/56305-getting-a-value-from-a-textbox-in-the-same-php-form/#findComment-278238 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']; ?> Link to comment https://forums.phpfreaks.com/topic/56305-getting-a-value-from-a-textbox-in-the-same-php-form/#findComment-278242 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. Link to comment https://forums.phpfreaks.com/topic/56305-getting-a-value-from-a-textbox-in-the-same-php-form/#findComment-278245 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. Link to comment https://forums.phpfreaks.com/topic/56305-getting-a-value-from-a-textbox-in-the-same-php-form/#findComment-278248 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 Link to comment https://forums.phpfreaks.com/topic/56305-getting-a-value-from-a-textbox-in-the-same-php-form/#findComment-278280 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.