tutostudio1

Pegando dados enviados usando o método POST

Aug 2nd, 2019
2,973
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5.     char *string = getenv( "CONTENT_LENGTH" );
  6.     int tamanho  = atoi( string );
  7.  
  8.     char vetor[tamanho + 1];
  9.  
  10.     fgets( vetor, tamanho + 1, stdin );
  11.  
  12.     printf( "Content-type: text/html\n\n" );
  13.     printf( "<html>\n" );
  14.     printf( "\t<head>\n" );
  15.     printf( "\t\t<meta charset=\"UTF-8\">\n" );
  16.     printf( "\t\t<title>Lendo dados do formulário</title>\n" );
  17.     printf( "\t</head>\n" );
  18.     printf( "\t<body>\n" );
  19.     printf( "\t\t<h1>Olá mundo!</h1>\n" );
  20.     printf( "\t\t<h1>Estou lendo: %s</h1>\n", vetor );
  21.     printf( "\t</body>\n" );
  22.     printf( "</html>\n" );
  23.     printf( "\n\n" );
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment