RE: [PHP] Re: Putting $_POST into string to send to ASP

2004-07-16 Thread Vail, Warren
How about (probably one of fifty solutions;

Foreach($_POST as $k = $v) $vals[] = $k.=.$v;
$strvals = urlencode(implode(,$vals));
Header(Location: https://example.com/script.asp?.$strvals);

One thing to think about, URL's are limited in length, and one reason for
using method=post is that they won't fit in a URL, for this you'll need to
make sure they fit.

Warren Vail


-Original Message-
From: Lars Torben Wilson [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 16, 2004 12:32 PM
To: Jeff Oien
Cc: PHP
Subject: [PHP] Re: Putting $_POST into string to send to ASP


Jeff Oien wrote:

 Dumb question, sorry if it's a repeat. I will use PHP for a form with
 error checking. When there are no errors I need to send all the 
 variables thru something like this:
 
 $URL = https://example.com/script.asp?First=JimLast=Smith;;
 urlencode($URL);
 header(Location: $URL\n);
 
 How do I gather up all the variables in $_POST and attach them as a
 string after the question mark? Thanks.
 Jeff

Try the http_build_query() function. If you don't have PHP 5, look in the
user notes--someone appears to have written one for PHP 4 as well (the user
note 21-Jun-2004 from 'brooklynphil'). I haven't tested either one.

   http://www.php.net/manual/en/function.http-build-query.php

Using this, you could just do something like:

   $query_string = http_build_query($_POST);


Hope this helps,

Torben [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Putting $_POST into string to send to ASP

2004-07-16 Thread Lars Torben Wilson
Vail, Warren wrote:
How about (probably one of fifty solutions;
Foreach($_POST as $k = $v) $vals[] = $k.=.$v;
$strvals = urlencode(implode(,$vals));
Header(Location: https://example.com/script.asp?.$strvals);
One thing to think about, URL's are limited in length, and one reason for
using method=post is that they won't fit in a URL, for this you'll need to
make sure they fit.
Warren Vail
You could do that, but for one thing, it doesn't handle arrays. The code
snippet in the user notes does.

--
Torben Wilson [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Putting $_POST into string to send to ASP

2004-07-16 Thread Jeff Oien
Thanks for the helpful examples. One other question. Is there an 
advantage to sending the URL via a header as opposed to doing http_post 
like this?
http://shiflett.org/hacks/php/http_post
Jeff

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Re: Putting $_POST into string to send to ASP

2004-07-16 Thread Vail, Warren
 You could do that, but for one thing, it doesn't handle 
 arrays. The code snippet in the user notes does.

You are absolutely correct, but I'm not sure that ASP could handle arrays
either.

On the other side Matt M.s processing should work better than mine;

foreach($_POST as $key = $value) {
   $arr[] = $key.'='.urlencode($value);
}

I believe my loop may change the  character to something it shouldn't?


Warren Vail


 -Original Message-
 From: Lars Torben Wilson [mailto:[EMAIL PROTECTED] 
 Sent: Friday, July 16, 2004 12:55 PM
 To: Vail, Warren
 Cc: 'Lars Torben Wilson'; Jeff Oien; PHP
 Subject: Re: [PHP] Re: Putting $_POST into string to send to ASP
 
 
 Vail, Warren wrote:
 
  How about (probably one of fifty solutions;
  
  Foreach($_POST as $k = $v) $vals[] = $k.=.$v;
  $strvals = urlencode(implode(,$vals));
  Header(Location: https://example.com/script.asp?.$strvals);
  
  One thing to think about, URL's are limited in length, and 
 one reason 
  for using method=post is that they won't fit in a URL, for 
 this you'll 
  need to make sure they fit.
  
  Warren Vail
 
 You could do that, but for one thing, it doesn't handle 
 arrays. The code snippet in the user notes does.
 
 
 
 -- 
 Torben Wilson [EMAIL PROTECTED]
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Putting $_POST into string to send to ASP

2004-07-16 Thread Matt M.
 Thanks for the helpful examples. One other question. Is there an
 advantage to sending the URL via a header as opposed to doing http_post
 like this?
 http://shiflett.org/hacks/php/http_post
 Jeff

Like someone mentioned earlier.  URL's have length limits.  That would
be one reason to do a post.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: Putting $_POST into string to send to ASP

2004-07-16 Thread Vail, Warren
If the hack works, it should get around the length limitation of the URL,
but I would be more tempted to use CURL for that.

http://www.php.net/manual/en/ref.curl.php

Warren Vail

Warren Vail
(415) 667-0240
SF211-07-434
 


-Original Message-
From: Jeff Oien [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 16, 2004 1:12 PM
To: PHP
Subject: Re: [PHP] Re: Putting $_POST into string to send to ASP


Thanks for the helpful examples. One other question. Is there an 
advantage to sending the URL via a header as opposed to doing http_post 
like this?
http://shiflett.org/hacks/php/http_post
Jeff

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Putting $_POST into string to send to ASP

2004-07-16 Thread Lars Torben Wilson
Jeff Oien wrote:
Thanks for the helpful examples. One other question. Is there an 
advantage to sending the URL via a header as opposed to doing http_post 
like this?
http://shiflett.org/hacks/php/http_post
Jeff
As mentioned a couple of times, size is one. But you still need to
url-encode the data if you're going to send it via post.
 ?php
 $data = array('item1' = 'value1', 'item2' = 'value2');
 $query_string = http_build_query($data);
 // Now, you can send the data either via post:
 $response = http_post('www.example.com', '/form.php', $data);
 // ...or via get:
 header('http://www.example.com?form.php?' . $data);
 ?
The first lets your script grab the output of the form to which
you're submitting (it's in $response after the http_post() call);
the second actually loads and displays the target form.
Another option is cURL, which is designed for exactly this sort
of thing:
  http://www.php.net/curl
...but it may or may not be overkill for what you need. However,
cURL pretty much rules the data posting/fetching game as far as
configurability etc.
Cheers,
Torben [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Re: Putting $_POST into string to send to ASP

2004-07-16 Thread Vail, Warren
I believe we all missed something important here, but I've been wrong
before.

Notice his URL below, specifically the https part.

I believe this means that the data not only needs to be URL encoded but SSL
encrypted.  I believe this makes a stronger case for using CURL, does it
not?  I also would mean that his hack code would not work.

Correct me if I'm wrong?

Warren Vail


-Original Message-
From: Lars Torben Wilson [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 16, 2004 12:32 PM
To: Jeff Oien
Cc: PHP
Subject: [PHP] Re: Putting $_POST into string to send to ASP


Jeff Oien wrote:

 Dumb question, sorry if it's a repeat. I will use PHP for a form with
 error checking. When there are no errors I need to send all the 
 variables thru something like this:
 
 $URL = https://example.com/script.asp?First=JimLast=Smith;;
 urlencode($URL);
 header(Location: $URL\n);
 
 How do I gather up all the variables in $_POST and attach them as a
 string after the question mark? Thanks.
 Jeff

Try the http_build_query() function. If you don't have PHP 5, look in the
user notes--someone appears to have written one for PHP 4 as well (the user
note 21-Jun-2004 from 'brooklynphil'). I haven't tested either one.

   http://www.php.net/manual/en/function.http-build-query.php

Using this, you could just do something like:

   $query_string = http_build_query($_POST);


Hope this helps,

Torben [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Putting $_POST into string to send to ASP

2004-07-16 Thread Jeff Oien
The client's vendor only specifies that it's field=data pairs and 
that it's URL encoded so I don't think that's an issue. But don't let 
that squelch any discussion. :)
Jeff Oien

Vail, Warren wrote:
I believe we all missed something important here, but I've been wrong
before.
Notice his URL below, specifically the https part.
I believe this means that the data not only needs to be URL encoded but SSL
encrypted.  I believe this makes a stronger case for using CURL, does it
not?  I also would mean that his hack code would not work.
Correct me if I'm wrong?
Warren Vail

Jeff Oien wrote:
Dumb question, sorry if it's a repeat. I will use PHP for a form with
error checking. When there are no errors I need to send all the 
variables thru something like this:

$URL = https://example.com/script.asp?First=JimLast=Smith;;
urlencode($URL);
header(Location: $URL\n);
How do I gather up all the variables in $_POST and attach them as a
string after the question mark? Thanks.
Jeff

Try the http_build_query() function. If you don't have PHP 5, look in the
user notes--someone appears to have written one for PHP 4 as well (the user
note 21-Jun-2004 from 'brooklynphil'). I haven't tested either one.
   http://www.php.net/manual/en/function.http-build-query.php
Using this, you could just do something like:
   $query_string = http_build_query($_POST);
Hope this helps,
Torben [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Putting $_POST into string to send to ASP

2004-07-16 Thread Justin Patrin
Thee is a PEAR package to do posts, gets, etc.

http://pear.php.net/package/HTTP_Request

On Fri, 16 Jul 2004 14:00:02 -0700, Vail, Warren [EMAIL PROTECTED] wrote:
 I believe we all missed something important here, but I've been wrong
 before.
 
 Notice his URL below, specifically the https part.
 
 I believe this means that the data not only needs to be URL encoded but SSL
 encrypted.  I believe this makes a stronger case for using CURL, does it
 not?  I also would mean that his hack code would not work.
 
 Correct me if I'm wrong?
 
 Warren Vail
 
 -Original Message-
 From: Lars Torben Wilson [mailto:[EMAIL PROTECTED]
 Sent: Friday, July 16, 2004 12:32 PM
 To: Jeff Oien
 Cc: PHP
 Subject: [PHP] Re: Putting $_POST into string to send to ASP
 
 Jeff Oien wrote:
 
  Dumb question, sorry if it's a repeat. I will use PHP for a form with
  error checking. When there are no errors I need to send all the
  variables thru something like this:
 
  $URL = https://example.com/script.asp?First=JimLast=Smith;;
  urlencode($URL);
  header(Location: $URL\n);
 
  How do I gather up all the variables in $_POST and attach them as a
  string after the question mark? Thanks.
  Jeff
 
 Try the http_build_query() function. If you don't have PHP 5, look in the
 user notes--someone appears to have written one for PHP 4 as well (the user
 note 21-Jun-2004 from 'brooklynphil'). I haven't tested either one.
 
http://www.php.net/manual/en/function.http-build-query.php
 
 Using this, you could just do something like:
 
$query_string = http_build_query($_POST);
 
 Hope this helps,
 
 Torben [EMAIL PROTECTED]
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 !DSPAM:40f8402e32021142355!
 
 


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php