Link to home
Start Free TrialLog in
Avatar of Buzzy Bee
Buzzy BeeFlag for United States of America

asked on

CGI and C--getting non-form variables

I am using an imagemap(.gif and .map)in my CGI script (written in C).  Along with the map I create a pulldown menu.  The user can use either the imagemap or the menu to make their choice.  I need to return 2 variables to my script.  The menu works fine because I can pass hidden input through and then use the cgic.c library to access those variables.

The problem is that I can't read the variables when the user uses the imagemap.  Entries in the .map file look like this:

poly http://.../cgi-bin/run?county=35&topic='C' 2,28 9,
56 5,64 43,64 44,30 2,28 2,28

When I do this, the cgiFormString function, etc. don't access the county and topic variables.  

QUESTION:  How do I read the non-form variables, using C?  What is the function/code that will allow me to access them when passed this way?  (NOTE:  I'm trying to stay away from the client side implementation of the image maps because the maps are huge)      
ASKER CERTIFIED SOLUTION
Avatar of mkornell
mkornell

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mkornell
mkornell

Actually, reflecting on your question, you are getting odd behavior.  cgic is supposed to transparently deal with the differences between GET and POST data.

As a test, write a program to display QUERY_STRING, both as cgic gets it and as it is set in the environment:

char *qs = getenv ("QUERY_STRING");
print ("<P>QS ENV:%s</P>", qs);
print ("<P>QS CGIC:%s</P>", cgiQueryString);

What does that tell you?

--mark;
Avatar of Buzzy Bee

ASKER

When I did what you said, I got the same thing both times:
   county=--&topic='C'
What you noticed is what I have a question about.  Why can't I read the variables?

Given this, do you have anymore input?

If you could take a moment and find what the parse function is, I would appreciate it.

-Webslider
Two more questions: 1) What is the request method?  Use:

print ("<P>QS CGIC:%s</P>", cgiRequestMethod);

to find out.

2) What version of cgic.c are you using

--mark;
I use 'POST' everywhere else, but when the imagemap is clicked on it uses 'GET'.

As far as the version goes, I imagine I have the newest one.  I got it from:
   http://www.ee.hwh.edu.tw/teach/cgic/cgic.html#obtain
not more than a month ago.

-webslider
I was looking through the latest cgic.c source code (version 1.05) and it will not read the QUERY_STRING variable if the method is POST, which would be one possible explanation for your problem.

If that's not it, email me your source code: mkornell@bridges.com