Search code examples
delphiphpmyadmindelphi-7

How can I connect to the database and PHPMyAdmin in Delphi


I want to make the registration process a user name and password. I use Delphi 7. Component which can be done? (I know very little english, sorry.)


Solution

  • http request is easiest method (with GET, or POST), but preferred you'll want to use SSL if you dont want passwords/usernames passed along to your webserver un-encrypted.

    Example of using POST request:

    uses
      IdHTTP;
    
    function PostData(const URL: string; Params: TStrings): string;
    var
      IdHTTP: TIdHTTP;
    begin
      Result := '';
      IdHTTP := TIDHttp.Create(nil);
      try
        IdHTTP.HandleRedirects := True;
        IdHTTP.ReadTimeout := 5000;
        Result := IdHTTP.Post(URL, Params);
      finally
        IdHTTP.Free;
      end;
    end;
    

    Optionally you can write your own socket, but that will be more difficult because you'll have to write your own listener. (Which is usually not allowed on most shared hosting plans.)