Jump to content

Pass Form (textarea) field values via url variable from Site A to Site B


Recommended Posts

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?

 

 

 

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.

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.

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.

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?

 

 

 

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!

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.