email forms 
Author Message
 email forms

Does anybody know why the commented out code in main() (below)
gives me the error "viewer not configured for file type
x-www-form-urlencoded" from Netscape?

The C code works for returning a form to user but when adding
the commented out code for writing a file and emailing it, it doesn't
work.

The Form (at bottom) works!
Gary
******************c code****************
#include <stdio.h>
#include <stdlib.h>

#define MAX_ENTRIES 300
#define LF 10
#define CR 13

struct an_entry
{
  char *name;
  char *val;

Quote:
} entries[MAX_ENTRIES];

char *makeword(line, stop)
char *line;
char stop;

{
  int x, y;
/*  char *word = (char *) malloc(sizeof(char) * (strlen(line) + 1));*/
  char *word;
  if ((word = malloc(sizeof(char) * (strlen(line) + 1))) == NULL)
    {
       printf("Error\n");
    }
  for (x=0; ((line[x]) && (line[x] != stop)); x++)
    word[x] = line[x];
  word[x] = '\0';
  if (line[x])
    ++x;
  y = 0;
  while (line[x])
    (line[y++] = line[x++]);
  line[y] = '\0';
  return word;

Quote:
}

char *fmakeword (f, stop, cl)
FILE *f;
char stop;
int *cl;
{
  int wsize = 2000;
  char *word;
  int i = 0;

/*  word = (char *) malloc(sizeof(char) * (wsize + 1));*/
  if ((word = malloc(sizeof(char) * (wsize + 1))) == NULL)
    printf ("Error\n");
  while(1)
  {
    word[i] = (char)fgetc(f);
    if (i == wsize)
    {
      word[i+1] = '\0';
      wsize += 2000;
      word = (char *) realloc(word,sizeof(char)*(wsize + 1));
      if ((word = realloc (word,sizeof(char)*(wsize + 1))) == NULL)
        printf ("Error\n");
    }
  --(*cl);
  if ( (word[i] == stop) || (feof(f)) || (!(*cl)) )
    {
       if (word[i] != stop)
         i++;
       word[i] = '\0';
       return word;
    }
  ++i;
  }

Quote:
}

char x2c(what)
char *what;
{
  register char digit;
  digit = (what[0] >= 'A' ? ((what[0] & 0xdf) - 'A')+10 : (what[0] - '0'));
  digit *= 16;
  digit += (what[1] >= 'A' ? ((what[1] & 0xdf) - 'A')+10 : (what[1] - '0'));
  return(digit);

Quote:
}

void unescape_url(url)
char *url;
{
  register int x,y;
  for (x = 0, y = 0; url[y]; ++x, ++y)
    {
      if ((url[x] = url[y]) == '%')
        {
           url[x] = x2c(&url[y+1]);
           y+=2;
        }
    }
  url[x] = '\0';

Quote:
}

void plustospace(str)
char *str;
{
  register int x;
  for (x=0; str[x]; x++)
    if (str[x] == '+')
      str[x] = ' ';

Quote:
}

main (argc, argv)      

int argc;
char *argv[];
{
  register int x, m=0;
  int cl;
/*  FILE *fp;*/
  printf("Content-type: text/html%c%c",10,10);
/*  if ((fp = fopen("/WWWserver/Web/rr/posts/post_file", "a")) == NULL)
    {
      fprintf(stderr, "Error opening file");
      exit(1);
    }*/
  if (strcmp(getenv("REQUEST_METHOD"), "POST"))
    {
      printf("This script should be referenced with a method of POST.\n");
      printf("If you don't understand this see this ");
      printf("<A HREF=\" http://www.*-*-*.com/ ;>forms overview</A>.%c",10);
      exit(1);
    }
  if (strcmp(getenv("CONTENT_TYPE"), "application/x-www-form-urlencoded"))
    {
       printf("This script can only be used to decode form results. \n");
       exit(1);
    }
  cl = atoi(getenv("CONTENT_LENGTH"));
  for (x=0; cl && (!feof(stdin)); x++)
    {
       m = x;
       entries[x].val = fmakeword(stdin, '&', &cl);
       plustospace(entries[x].val);
       unescape_url(entries[x].val);
       entries[x].name = makeword(entries[x].val, '=');
    }
  printf("<h1>Query results</h1>");
  printf("You submitted the following name/value pairs:<p>%c",10);
  printf("<ul>%c",10);

  for (x=0; x <= m; x++)
    printf("<li> <code>%s = %s</code>%c", entries[x].name, entries[x].val,10);
    printf("</ul>%c",10);
/*
  for (x=0; x <= m; x++)
    fprintf(fp,"%s %s", entries[x].name, entries[x].val);
  close (fp);

Quote:
}

****************************************************************
<html>
<head><!--reqappl.html-->
<title>Request for Air Force Academy Application</title>
</head>
<body>
<center>
<h1><b>Request for Air Force Academy Application</b></h1>
<blink>(Submit only once.  Deadline is 31 December prior to entering year.)</blink><p>
<b>Please type or print clearly</b><p>
<IMG SRC="/c|/line1.jpg"></IMG>
</center>
THIS FORM IS SUBJECT TO THE PRIVACY ACT OF 1974.  AUTHORITY:  10 U.S.C. Chapter 903,
United States Air Force Academy.  PRINCIPLE PURPOSE:  Information will be used by the
USAFA for admissions.  ROUTINE USES:  None.  DISCLOSURE IS VOLUNTARY.  However,
without submission of ALL the requested information, eligibility for selection cannot
be made.  Social Security Number (SSN) is used as a means of identification.
<CENTER><IMG SRC="/c|/line1.jpg"></IMG></CENTER>
<form method="POST" action="/cgi-bin/forms">
<pre>
Social Security Number (SSN)             :  <input name="ssan" size="9" MAXLENGTH="9">
Year of High School Graduation           :  <input name="grad" size="4" MAXLENGTH="4">
Full Name (Last, First, Middle)          :  <input name="name" size="30" MAXLENGTH="30">
Number and Street                        :  <input name="addr" size="45" MAXLENGTH="45">
Apartment Number                         :  <input name="apt" size="6" MAXLENGTH="6">
City                                     :  <input name="city" size="45" MAXLENGTH="45">
State                                    :  <input name="state" size="2" MAXLENGTH="2">
Zip Code                                 :  <input name="zip" size="10" MAXLENGTH="10">
Country                                  :  <input name="country" size="45" MAXLENGTH="45">
Home Telephone Number (include Area Code):  <input name="tele" size="20" MAXLENGTH="20">
Date of Birth (Month, Day, Year)         :  <input name="bdate" size="6" MAXLENGTH="6">
Name of High School                      :  <input name="hsname" size="30" MAXLENGTH="30">
High School ETS Code (If Known)          :  <input name="ets" size="8" MAXLENGTH="8">
<CENTER><IMG SRC="/c|/line1.jpg"></IMG>
</CENTER>
<center>Optional Data</center>
<CENTER><IMG SRC="/c|/line1.jpg"></IMG>
</CENTER>
<input type="radio" name="amer-indian" value="American Indian">American Indian
<input type="radio" name="asian-american" value="Asian-American">Asian-American
<input type="radio" name="african-american" value="African-American">African-American
<input type="radio" name="caucasian" value="Caucasian">Caucasian
<input type="radio" name="other" value="Other">Other<p>
<input type="submit">
</pre>
</form>
<CENTER><IMG SRC="/c|/line1.jpg"></IMG>
</CENTER>
<CENTER><b>IN LIEU OF USAFA FORM O-125, FEB 95 (HQ USAFA/RREK)<P>
PREVIOUS EDITION WILL BE USED</B></CENTER>
<CENTER><IMG SRC="/c|/line1.jpg"></IMG>
</CENTER>
<a HREF="adms.html"><IMG SRC="/c|/icons/home01.gif"></IMG></a>Return to Admissions homepage
<p>

Department today!
</body>
</html>


Sun, 11 Jan 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. email form under win95

2. Attempting To Send Email From ASPX Web Form

3. cgic form-to-email gateway

4. Free HTML form-to-email cgi script

5. earn money-just click the link in the email,then fill the form

6. earn money-just click the link in the email,then fill the form

7. earn money-just click the link in the email,then fill the form

8. earn money-just click the link in the email,then fill the form

9. earn money-just click the link in the email,then fill the form

10. email question : customized email header by c language ??

11. Launching a Form as a pop up type form

12. form to form

 

 
Powered by phpBB® Forum Software