AKB Forums

Go Back   AKB Forums > Technical sections > Languages, Compilers and Interpreters
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Languages, Compilers and Interpreters C,C++,C#,.NET,Java,PHP,Perl,SQL and more

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old May 9, 2005, 16:47   #1
incomer
 
BlackCode's Avatar
 
Join Date: Feb 2005
Location: Yerevan
Posts: 16
Rep Power: 0
Reputation: 10
Send a message via ICQ to BlackCode
Question problem of sending data with POST method

I have Apache2 server and PHP4 installed on my local computer for educational purposes.

I have the index2.php in my http server directory which prints the myvar variables value.
Code:
<?php 

echo '<html><head><title></title></head><body><p>';
echo $_POST["myvar"];
echo '</p></body></html>';

?>
This thing is working fine when I post data from the index2.htm file,

Code:
<html><head><title>My PHP Query Page</title></head><body><br><br><center>

<form action="index2.php" method="post">
<p> <input type="text" name="myvar">
<input type="submit" value="Submit Query">
<input type="reset" value="   Reset   ">
</p></form>
</center>

</body></html>
but it doesn't work when I try to post some data using HttpOpenRequest(...), HttpSendRequest(...) WinINET APIs.

Code:
#include <windows.h>
#include <wininet.h>

#include <iostream>

using std::cout;

void main()
{
HINTERNET hInternet = InternetOpen(
      	"MyAgent",
      	INTERNET_OPEN_TYPE_DIRECT,
      	NULL,
      	NULL,0);
cout<<"hInternet="<<(int)hInternet<<"\nGetLastError()="<<GetLastError()<<"\n\n";

	HINTERNET hConnect = InternetConnect(
      	hInternet,
      	"127.0.0.1",
      	80,
      	NULL,
      	NULL,
      	INTERNET_SERVICE_HTTP,
      	0,
      	0);
	cout<<"hConnect="<<(int)hConnect<<"\nGetLastError()="<<GetLastError()<<"\n\n";

	LPCTSTR AcceptTypes[] = { TEXT("*/*"), NULL}; 
	HINTERNET hRequest = HttpOpenRequest(
      	hConnect,
      	"POST",
      	"/index2.php",
      	NULL,
      	NULL,
      	AcceptTypes,
      	INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_RELOAD | INTERNET_FLAG_PRAGMA_NOCACHE,
      	0);
	cout<<"hRequest="<<(int)hRequest<<"\nGetLastError()="<<GetLastError()<<"\n\n";

	char optData[] = "?myvar=31";

	BOOL retRes = HttpSendRequest(
      	hRequest,
      	0,
      	0,
      	optData,
      	lstrlen(optData)
      	);
	cout<<"retRes="<<(int)retRes<<"\nGetLastError()="<<GetLastError()<<"\n\n";

	auto char  buffer[4096];
	auto DWORD uLong;

	if(InternetReadFile(hRequest,buffer,4096,&uLong) == FALSE){
  MessageBox(0,"ERROR InternetReadFile returns NULL","ERROR",0);
        return;
	}

	for(UINT i=0;i<uLong;i++){
  cout<<buffer[i];
	}

	Sleep(20000);
}
The server respond like it doesn't receive any data.

Code:
<html><head><title></title></head><body><p><br>
<b>Warning</b>:  Undefined index:  myvar in <b>D:\!!HTTP!!\WWW\index2.php</b> on line <b>4</b><br>
</p></body></html>
I posted the optData string with the InternetSendRequest(...)

optData[] = "?myvar=31";

is it right ?
what I made wrong ?
__________________
Regards, Aram
BlackCode is offline   Reply With Quote Quote selected
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird problem in WinXP Boyov Software 4 May 4, 2005 17:11
Russian kodirovka problem ! (PHP/Javascript) Barew_dzez Web Development 0 Apr 6, 2005 12:45
Pancake flipping problem acid Algorithms 1 Jun 2, 2004 19:16
SMS sending problem maxus Telecom 5 Apr 4, 2004 16:58
Problem with a project !!! nayapaltan Software Security 1 Oct 23, 2001 15:51


All times are GMT. The time now is 00:12.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link