How to send data using IdHTTP to PHP script

M

malborg

I have simple form in PHP with two input types as text to input login
name and password.PS: They use POST method. (index.php)

The other script(logowanie.php) checks if login and password is correct
and displays: "You are loged in." or "Your password or login name is
incorrect."
I'm trying to login using IdHTTP from Indy components. But in response
from script I have everything what contains "index.php" but no values
for login name and no values for password.
What I'm doing wrong ??
I think that "index.php" does not receive any data from method
IdHTTP->Post();
Please help :(

#include <vcl.h>
#include<iostream.h>
#include<fstream.h>
#pragma hdrstop
#include <string.h>
#include "Unit1.h"
//#include "Unit3.h"
#include "Unit2.h"
#include "Unit3.h"
#include <Clipbrd.hpp>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "SHDocVw_OCX"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{

AnsiString s="http://something.com/arthur/web/" ;



TMemoryStream *Receive = new TMemoryStream() ;
AnsiString rtf;
TStringStream * Send = new TStringStream(rtf) ;
IdHTTP1->Request->Accept="*/*";
IdHTTP1->Request->Referer="http://something.com";
IdHTTP1->Request->ContentType="application/x-www-form-urlencoded";
Send->WriteString("?log=a&pass=a");



IdHTTP1->Post("http://something.com/arthur/web/index.php?log=a&pass=a",Send,Receive);
Receive->SaveToFile("Response.txt");
CppWebBrowser1->Navigate(WideString(s));



This is index.php
<HTML>
<BODY align=center>
<form method="POST" action="logowanie.php">
<center>

<?
echo
"LOGIN:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
";
?>
<input type="text" name=log value="">
<br><br>
<?
echo
"PASSWORD:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
";
?>
<input type="password" name=pass value="">
<input type="hidden" name=drhide>
<br><br>
<input type="submit" value="Login">
<input type="button" value="BUTTON">
</center>
</form>

</BODY>
</HTML>

This is logowanie.php
<?

$login = 'a';
$password = 'a';

if ( ($login == $_POST['log']) && ($password == $_POST['pass']) )
{

echo "You are loged";
}
else
{
echo 'ACCESS DENIED ';
}
?>
 
W

williamsio

<?
$Var = $_POST['Nombres'];
$roughHTTPPOST = readfile("php://input");
echo $roughHTTPPOST;
?>
<form name="form1" method="post" action="post.php">
<input type="text" name="Nombres">
<input type="submit" name="Submit" value="Enviar">
</form>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,965
Messages
2,570,148
Members
46,710
Latest member
FredricRen

Latest Threads

Top