B
bpascal123
Hi,
I'm implementing a simple c script from a book as a server cgi-bin executable.
I would like the result of the script to be displayed in the same web page from which it is called
Example:
The html page that hosts the form and calls simplest.cgi
<FORM ACTION = "cgi-bin/simplest.cgi" METHOD="POST">
<p><i>Search info from this form using cgi script</i></p>
<br />
<p>Title <INPUT TYPE="TEXT" SIZE=20 NAME="titre"></p>
<br />
<p><INPUT TYPE="SUBMIT" VALUE=" Search ">
</FORM>
simplest.cgi looks like this
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXL 132
int main(int arg, char *argv[]){
/* Phase 1 variables */
int lg ;
char ligne[MAXL];
printf ("Content-type: text/html\n\n");
printf ("<HEAD><TITLE>Résultat de la recherche</TITLE>");
printf ("</HEAD><BODY bgcolor=white>");
printf ("<H1><CENTER>Résultat de la recherche</CENTER></H1>");
/* Phase 1 Extraction des paramètres */
lg = atoi (getenv("CONTENT_LENGTH"));
fgets(ligne, lg+1, stdin);
printf("<B>Paramètres :</B> %s<P>\n", ligne);
return 0;
}
Can I include the printf function to show its argument directly on the htmlpage above?
Thanks
Pascal
I'm implementing a simple c script from a book as a server cgi-bin executable.
I would like the result of the script to be displayed in the same web page from which it is called
Example:
The html page that hosts the form and calls simplest.cgi
<FORM ACTION = "cgi-bin/simplest.cgi" METHOD="POST">
<p><i>Search info from this form using cgi script</i></p>
<br />
<p>Title <INPUT TYPE="TEXT" SIZE=20 NAME="titre"></p>
<br />
<p><INPUT TYPE="SUBMIT" VALUE=" Search ">
</FORM>
simplest.cgi looks like this
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXL 132
int main(int arg, char *argv[]){
/* Phase 1 variables */
int lg ;
char ligne[MAXL];
printf ("Content-type: text/html\n\n");
printf ("<HEAD><TITLE>Résultat de la recherche</TITLE>");
printf ("</HEAD><BODY bgcolor=white>");
printf ("<H1><CENTER>Résultat de la recherche</CENTER></H1>");
/* Phase 1 Extraction des paramètres */
lg = atoi (getenv("CONTENT_LENGTH"));
fgets(ligne, lg+1, stdin);
printf("<B>Paramètres :</B> %s<P>\n", ligne);
return 0;
}
Can I include the printf function to show its argument directly on the htmlpage above?
Thanks
Pascal