Delphi Pages Forums

Delphi Pages Forums (http://www.delphipages.com/forum/index.php)
-   General (http://www.delphipages.com/forum/forumdisplay.php?f=2)
-   -   TIdHTTP.Post ? (http://www.delphipages.com/forum/showthread.php?t=208992)

Jeffijoe 12-02-2010 09:49 AM

TIdHTTP.Post ?
 
Hey peeps. :)

I am writing a PHP script, which will only be used to receive and process stuff sent from my Delphi Application. I currently use HTTP.Get(); to get the output of the PHP script, but then I have to use $_GET[]; in my PHP script, which gets its values from the parameters sent from the URL. I want to use $_POST[]; in my script, so the parameters are not visible in the URL string, but how do I post data to my php script from Delphi? Like, when you use the Form tag in HTML to do it?
<form>
I hope you understand what I am looking for. :)

Thanks.
- Jeff</form>

MrBaseball34 12-02-2010 06:02 PM

Do it the same way as here:
http://www.delphipages.com/forum/sho...50&postcount=4

Then make sure you use the $_POST variable in your PHP script.

MrBaseball34 12-02-2010 06:04 PM

Use this URLEncode function, it is much smaller:
Code:

function URLEncode(const ASrc: string): string;
var
  i: Integer;
const
  UnsafeChars = ['*', '#', '%', '<', '>', ' ','[',']'];  {do not localize}
begin
  Result := '';    {Do not Localize}
  for i := 1 to Length(ASrc) do
  begin
    if (ASrc[i] in UnsafeChars) or (not (ord(ASrc[i])in [33..128])) then
    begin {do not localize}
      Result := Result + '%' + IntToHex(Ord(ASrc[i]), 2);  {do not localize}
    end
    else
    begin
      Result := Result + ASrc[i];
    end;
  end;
end;


Jeffijoe 12-02-2010 06:32 PM

Quote:

Originally Posted by MrBaseball34 (Post 213568)
Use this URLEncode function, it is much smaller:
Code:

function URLEncode(const ASrc: string): string;
var
  i: Integer;
const
  UnsafeChars = ['*', '#', '%', '<', '>', ' ','[',']'];  {do not localize}
begin
  Result := '';    {Do not Localize}
  for i := 1 to Length(ASrc) do
  begin
    if (ASrc[i] in UnsafeChars) or (not (ord(ASrc[i])in [33..128])) then
    begin {do not localize}
      Result := Result + '%' + IntToHex(Ord(ASrc[i]), 2);  {do not localize}
    end
    else
    begin
      Result := Result + ASrc[i];
    end;
  end;
end;



Hi MrBaseBall,

Thanks for your reply, however I got my code fixed, and I wrote a class to do it for me. Thanks anyway. :)

What does that function do?

MrBaseball34 12-02-2010 08:13 PM

What does the function name say? It uncodes a string so that it can be passed as a URL.

Jeffijoe 12-03-2010 10:10 AM

Quote:

Originally Posted by MrBaseball34 (Post 213570)
What does the function name say? It uncodes a string so that it can be passed as a URL.

Don't see where I need that in my app. Thanks anyways :)

MrBaseball34 12-03-2010 02:19 PM

Quote:

Originally Posted by Jeffijoe (Post 213576)
Don't see where I need that in my app. Thanks anyways :)

If you are going to send anything via HTTP POST you will.

MrBaseball34 12-03-2010 02:20 PM

So, have you gotten the info you need to make the change in your app to use POST vs. GET?

Jeffijoe 12-03-2010 03:06 PM

Quote:

Originally Posted by MrBaseball34 (Post 213580)
If you are going to send anything via HTTP POST you will.

Well, I got my app working just fine. =)

Will add it though, cheers.


All times are GMT. The time now is 04:48 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.