Dobra jako przyklad cos takiego:
index.php
<html>
<form action="login.php" method="POST"><b>
login:<br/><input type="text" name="login"/><br/>
haslo:<br/><input type="password" name="pass"/><br/>
</b><input type="submit" value="wyslij"/>
</form>
</html>
login.php
<?php
if($_POST['login'] == 'tomek' and $_POST['pass'] == 'tajne') {
echo "zalogowany<br/>\n";
} else {
echo "lipa<br/>\n";
}
?>
tutaj kod wysylajacy zapytanie
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#define REQUEST "POST /costam/login.php HTTP/1.1\r\n"\
"Host: localhost\r\n"\
"Content-Type: application/x-www-form-urlencoded\r\n"\
"Content-Length: 22\r\n\r\n"\
"login=tomek&pass=tajne"
#define SIZE 1024
int main(void)
{
int sock, i; char buff[SIZE] = {0};
struct sockaddr_in sin;
struct hostent *hos;
sock = socket(AF_INET, SOCK_STREAM, 0);
memset(&sin, '\0', sizeof(struct sockaddr_in));
sin.sin_family = AF_INET;
sin.sin_port = htons(PORT);
sin.sin_addr.s_addr = inet_addr("127.0.0.1");
connect(sock, (struct sockaddr*)&sin, sizeof(struct sockaddr));
write(sock, REQUEST, sizeof(REQUEST));
read(sock, buff, sizeof(buff));
for(i = 0; i < SIZE; i++)
putchar(buff[i]);
puts("");
close(sock);
return 0;
}