ultrasound0000 Posted February 11, 2009 Share Posted February 11, 2009 This might be simple but I'm stuck. I have a simple form on my site with a textarea for users to enter their FedEx shipping tracking numbers. Then I want to pass the textarea value(s) (tracking numbers), that users enter to the FedEx tracking page (http://fedex.com/Tracking?tracknumbers=) as a URL variable. The url variable in this case is called tracknumbers Here is the code I have so far: <form id="form1" name="form1" method="post" action="http://fedex.com/Tracking?tracknumbers=<?php echo $_GET['trackTxtArea']; ?>"> <span>Please enter your tracking number:</span> <div id="trackTxtArea" class="textarea"> <textarea name="trackTxtArea" id="trackTxtArea" cols="30" rows="2"></textarea> <span class="textareaRequiredMsg">Please enter a tracking number</span> </div> <input type="submit" name="trackSubmit" id="trackSubmit" value="" class="trackSubmit"/> </form> However, I'm not getting anything passed over. I tried using POST in the url echo but that did not work either. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/144816-pass-form-textarea-field-values-via-url-variable-from-site-a-to-site-b/ Share on other sites More sharing options...
premiso Posted February 11, 2009 Share Posted February 11, 2009 You would have to do this via javascript using the onsubmit or do it on the page reload: <?php if (isset($_GET['trackTxtArea'])) { header('Location: http://fedex.com/Tracking?tracknumbers=' . $_GET['trackTxtArea']); exit; } ?> <form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']?>"> <span>Please enter your tracking number:</span> <div id="trackTxtArea" class="textarea"> <textarea name="trackTxtArea" id="trackTxtArea" cols="30" rows="2"></textarea> <span class="textareaRequiredMsg">Please enter a tracking number</span> </div> <input type="submit" name="trackSubmit" id="trackSubmit" value="" class="trackSubmit"/> </form> Should work for a php example. Quote Link to comment https://forums.phpfreaks.com/topic/144816-pass-form-textarea-field-values-via-url-variable-from-site-a-to-site-b/#findComment-759906 Share on other sites More sharing options...
ultrasound0000 Posted February 11, 2009 Author Share Posted February 11, 2009 Hi Premiso and thanks for the reply. I tried your suggestion but it's not working for some reason. When I put something in the textarea it refreshes the original page and does not go anywhere, so it posts to self. It looks like it's going through the if statement but not processing the header location code. Quote Link to comment https://forums.phpfreaks.com/topic/144816-pass-form-textarea-field-values-via-url-variable-from-site-a-to-site-b/#findComment-759922 Share on other sites More sharing options...
ultrasound0000 Posted February 11, 2009 Author Share Posted February 11, 2009 Actually it looks like it's not going through the if statement at all, so it just posts to self without redirecting. Quote Link to comment https://forums.phpfreaks.com/topic/144816-pass-form-textarea-field-values-via-url-variable-from-site-a-to-site-b/#findComment-759925 Share on other sites More sharing options...
premiso Posted February 11, 2009 Share Posted February 11, 2009 Sorry, I got mixed up with the post/get thing. <?php if (isset($_POST['trackTxtArea'])) { header('Location: http://fedex.com/Tracking?tracknumbers=' . $_POST['trackTxtArea']); exit; } ?> Replace that and it should work. Quote Link to comment https://forums.phpfreaks.com/topic/144816-pass-form-textarea-field-values-via-url-variable-from-site-a-to-site-b/#findComment-759927 Share on other sites More sharing options...
ultrasound0000 Posted February 11, 2009 Author Share Posted February 11, 2009 Definitely looks like this would work but I'm getting an error message: Warning: Cannot modify header information - headers already sent by (output started at /mnt/local/home/public_site/www4/support/index.php:87) in /mnt/local/home/public_site/www4/support/index.php on line 115 I don't have a config file and I copied and pasted the code from here through textEdit (similar to Notepad for PC) into Dreamweaver editor. Any idea why I'm getting this error message? Quote Link to comment https://forums.phpfreaks.com/topic/144816-pass-form-textarea-field-values-via-url-variable-from-site-a-to-site-b/#findComment-759939 Share on other sites More sharing options...
premiso Posted February 11, 2009 Share Posted February 11, 2009 Yea, you have output on line 87. The header tag has to be called before any output is sent to the browser. Quote Link to comment https://forums.phpfreaks.com/topic/144816-pass-form-textarea-field-values-via-url-variable-from-site-a-to-site-b/#findComment-759940 Share on other sites More sharing options...
ultrasound0000 Posted February 11, 2009 Author Share Posted February 11, 2009 Ok I'm a newbie so I guess I'm allowed these kind of errors for now It works very well. However, since this is a textarea, when I enter more than one tracking number in a separate line in the text box I get the following error message: Warning: Header may not contain more than a single header, new line detected. in /mnt/local/home/public_site/www4/support/index.php on line 3 It works fine if I enter the tracking numbers separated by a comma, but it breaks if they are entered in individual lines (and I'm sure users will enter them in individual lines eventually!) Thanks for all your help! Quote Link to comment https://forums.phpfreaks.com/topic/144816-pass-form-textarea-field-values-via-url-variable-from-site-a-to-site-b/#findComment-759951 Share on other sites More sharing options...
ultrasound0000 Posted February 11, 2009 Author Share Posted February 11, 2009 One more thing: I'm trying to have the Fedex page open in a new window. I'm assuming this would not be possible through the PHP header function, any ideas? These are additional things, but my main issues is fixed so I'll set this post as solved. Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/144816-pass-form-textarea-field-values-via-url-variable-from-site-a-to-site-b/#findComment-759967 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.