Thread: Form processing : storing strings in arrays

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    1

    Form processing : storing strings in arrays

    I am trying to write a function that "captures" the names of .jpeg files from a web form and compare these to the jpeg files that I have stored in my local directory.

    Can anyone clue me in? How do I pass the inputs from a HTML form into a sorted array? I know that image filenames are to be stored as strings in char array but I am not sure how to do it.

    In a html form
    -----------------
    Images:

    Image1.jpg
    Image2.jpg
    Image3.jpg
    .......
    .......
    Image?.jpg
    ----------------

    Code:
    void scanDirectory(void) / / / / / / / / / / 
    {
       char *Images =  
       field->getValue("Images");
       if (Images == NULL) errorTerminate  
       ("No image field found in the form!     
          \n ");
       if(strncmp(Images,"Images", 9)==0)
    	errorTerminate("Image names  
            not specified");
    
       else ??
    }
    D.A.C

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >How do I pass the inputs from a HTML form into a sorted array?
    Read from stdin. That is an aspect of CGI programming that many are surprised with at first, to read from a form or other such GET function all you have to do is read from stdin with whatever works best. I would suggest fgets.

    -Prelude
    My best code is written with the delete key.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by Prelude
    I would suggest fgets.

    -Prelude
    I hear that gets works best for CGI due to its enhanced security features.

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I hear that gets works best for CGI due to its enhanced security features.
    It depends on who you are talking about when it comes to security.

    -Prelude
    My best code is written with the delete key.

  5. #5
    Registered User
    Join Date
    May 2002
    Posts
    132
    Now it all depends on whether your form is using the method GET or POST. For full details check out:

    http://www.cs.rpi.edu/~hollingd/netprog99/cgi.html

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Please don't reply to age old threads, this conversation was over some 5 months ago.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. storing strings in arrays
    By smp in forum C Programming
    Replies: 6
    Last Post: 12-16-2008, 09:37 AM
  2. storing strings by enum/s
    By l2u in forum C++ Programming
    Replies: 2
    Last Post: 10-07-2008, 08:03 AM
  3. Logic help with strings and arrays.
    By logithx in forum C Programming
    Replies: 2
    Last Post: 09-12-2008, 09:31 AM
  4. arrays of strings
    By mbooka in forum C Programming
    Replies: 2
    Last Post: 02-19-2006, 07:55 PM
  5. arrays of char strings
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 10-24-2001, 04:46 PM