#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char *cognome=NULL;
char *nome=NULL;
char *email=NULL;
char *password=NULL;
char *password2=NULL;
FILE *file_utenti=NULL;
file_utenti=fopen("Utenti.dat","a+");
struct utente
{
char cognome[25];
char nome[25];
char email[80];
char password[64];
char password2[64];
};
struct utente Utente;
file_utenti=fopen("Utenti.dat","r");
if(file_utenti!=NULL)
printf("%s\n","File aperto correttamente in lettura");
else
printf("%s\n","Impossibile leggere sul file utenti");
while(fread(&Utente, sizeof(Utente), 1, file_utenti))
{
printf("%s\t",Utente.cognome);
printf("%s\t",Utente.nome);
printf("%s\t",Utente.email);
printf("%s\t",Utente.password);
printf("%s\t",Utente.password2);
printf("\n");
}
fclose(file_utenti);
return 0;
}
If I run it as a cgi script, it doesn't enter the while, but it works perfectly if I run it in /var/www/cgi-bin/ directory. It opens the file, print all the records, and then quits Of course, I used html tag in my cgi script. I mean, I used a table to show data from the file But it only writes the tag table