Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sending data pack with POST to script...

Posted on 2004-03-27
3
Medium Priority
?
192 Views
Last Modified: 2010-04-05
there are simple example how to send POST DATA
QUESTION : how i can send a lot off data whith one POST sending...


<?php
  if ((isset($_POST['username'])) && (isset($_POST['password']))) {
    echo 'OK';
  }  else {
    echo 'Error! Insufficient parameters!';
  }
?>

and at the Delphi side:

var
  ResultString: string;
  PostStrings: TStringList;
begin
  PostStrings := TStringList.Create;
  try
    PostStrings.Add('UserName=hello');
    PostStrings.Add('Password=world');
    ResultString := IdHTTP1.Post('http://www.test.com/login.php', PostStrings);
    if ResultString = 'OK' then
      ShowMessage('All OK!')
    else raise Exception.Create(ResultString);
  finally
    PostStrings.Free;
  end;
end;
0
Comment
Question by:andrezzz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Expert Comment

by:IrishFBall32
ID: 10695349
Im not exactly sure what you ment by sending a lot of data, so ill try to cover all the bases...

if by a lot of data you mean many variables then simply add more poststrings.add lines like so:
[code]
try
    PostStrings.Add('UserName=hello');
    PostStrings.Add('Password=world');
    PostStrings.Add('var1=foo');
    PostStrings.Add('var2=bar');
    PostStrings.Add('var3=blah1');
    PostStrings.Add('var4=blah2');
    ResultString := IdHTTP1.Post('http://www.test.com/login.php', PostStrings);
    <snip>
[/code]

If a lot of means a particularly large variable then you should be able to send it the same way you send the small ones as such:
[code]
try
    PostStrings.Add('UserName=reallyreallyreallyreallyreallyreallyreallyreallyreallylongusername');
    PostStrings.Add('Password=world');
    ResultString := IdHTTP1.Post('http://www.test.com/login.php', PostStrings);
    <snip>
[/code]

If you just mean being able to send the value of a variable then you can do the following:
[code]
var
  ResultString,
  UserNameString,
  PasswordString : string;
  PostStrings: TStringList;
<snip>
try
    PostStrings.Add('UserName='+UserNameString);
    PostStrings.Add('Password='+PasswordString);
    ResultString := IdHTTP1.Post('http://www.test.com/login.php', PostStrings);
    <snip>
[/code]
0
 

Author Comment

by:andrezzz
ID: 10695369
if one record is:
----- one record-------
name=some name
surname=same surname
date=reg date
info1= some information
info2= some information
...
info20= some information
---------------------
and I need to send about 100 this records with various data WITH ONE POST...

0
 
LVL 1

Accepted Solution

by:
IrishFBall32 earned 1000 total points
ID: 10695830
i would have to say that as far as i know that cannot be done, at least not cleanly anyway...

you could try doing it by creating a record object like so...
type
  ARecord = record
    name,
    surname,
    info1,
    info2,
    ...
    info20 : string;
    regdate : tdatetime;
  end;
var
  allrecords : array of ARecord;
  i : integer;

Then the posting would go something like this...
for i := 0 to allrecords.high do begin
  poststrings.add('Record'+inttostr(i)+'='+allrecords[i]
end;
ResultString := IdHTTP1.Post('http://www.test.com/login.php', PostStrings);

The script for handling this data would have to be reworked to be able to handle any amount of variables in the form of Recordx where x represents the record number... It would also have to be able to parse out each record in order to get at its constituent parts, but that shouldnt be too hard...

that is the best i can think of for sending it in a single posting... out of curiosity why must it only use one post? The program could be much cleaner if each record could have its own post.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question