Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 12-02-2010, 09:49 AM
Jeffijoe Jeffijoe is offline
Senior Member
 
Join Date: Nov 2009
Posts: 149
Default 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?

I hope you understand what I am looking for.

Thanks.
- Jeff

Last edited by Jeffijoe; 12-02-2010 at 02:33 PM.
Reply With Quote
  #2  
Old 12-02-2010, 06:02 PM
MrBaseball34 MrBaseball34 is offline
Senior Member
 
Join Date: Jan 2001
Posts: 7,260
Default

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

Hook 'em Horns
2005 College Football National Champions
2005 College Baseball National Champions
Reply With Quote
  #3  
Old 12-02-2010, 06:04 PM
MrBaseball34 MrBaseball34 is offline
Senior Member
 
Join Date: Jan 2001
Posts: 7,260
Default

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;
__________________
MrBaseball34

Hook 'em Horns
2005 College Football National Champions
2005 College Baseball National Champions
Reply With Quote
  #4  
Old 12-02-2010, 06:32 PM
Jeffijoe Jeffijoe is offline
Senior Member
 
Join Date: Nov 2009
Posts: 149
Default

Quote:
Originally Posted by MrBaseball34 View Post
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?
Reply With Quote
  #5  
Old 12-02-2010, 08:13 PM
MrBaseball34 MrBaseball34 is offline
Senior Member
 
Join Date: Jan 2001
Posts: 7,260
Default

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

Hook 'em Horns
2005 College Football National Champions
2005 College Baseball National Champions
Reply With Quote
  #6  
Old 12-03-2010, 10:10 AM
Jeffijoe Jeffijoe is offline
Senior Member
 
Join Date: Nov 2009
Posts: 149
Default

Quote:
Originally Posted by MrBaseball34 View Post
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
Reply With Quote
  #7  
Old 12-03-2010, 02:19 PM
MrBaseball34 MrBaseball34 is offline
Senior Member
 
Join Date: Jan 2001
Posts: 7,260
Default

Quote:
Originally Posted by Jeffijoe View Post
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

Hook 'em Horns
2005 College Football National Champions
2005 College Baseball National Champions
Reply With Quote
  #8  
Old 12-03-2010, 02:20 PM
MrBaseball34 MrBaseball34 is offline
Senior Member
 
Join Date: Jan 2001
Posts: 7,260
Default

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

Hook 'em Horns
2005 College Football National Champions
2005 College Baseball National Champions
Reply With Quote
  #9  
Old 12-03-2010, 03:06 PM
Jeffijoe Jeffijoe is offline
Senior Member
 
Join Date: Nov 2009
Posts: 149
Default

Quote:
Originally Posted by MrBaseball34 View Post
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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 10:03 AM.


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