Link to home
Start Free TrialLog in
Avatar of GSD4ME
GSD4ME

asked on

C handling of HTML forms

I'm a first-timer trying to develop a web page and have got so far in the development cycle before running out of knowledge.
I can create HTML forms on my web page and have figured out how to submit the data back to my CGI programon the ISP.

However, what I don't understand is in what form do they arrive at my program? I want to write the CGI program in 'C' (i don't know much else I'm afraid and am too old to handle anything new ike Java or Perl!) and need to extract the form data sent to me.

Secondly, when I have got stuff to send back, how  do I do it to update the form? I think I understand that I need to send back HTML 'commands' to my web page but how does my web page 'know' what to do with the data sent? Does the page autorefresh when it receives the HTML? and how do I ensure that the data I am sending back to my page goes in the correct areas of my page?
ASKER CERTIFIED SOLUTION
Avatar of mubarmej
mubarmej

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 GSD4ME
GSD4ME

ASKER

That is VERY comprehensive and VERY helpful.

The area I find most surprising is that to 'refresh' the page is that I have to send the WHOLE of my page back in its HTML.
I guess that I am going to have to redesign my web pages to make it simpler as the form resides on a page that has lots of other things associated with it - instructions what to do, HTML form items etc etc.!

Can I easily create a sub-page that displays the data sent back from the ISP/my program rather than 'refreshing' the original?
GSD4ME ..

There are a couple of ways to do that ..

One way is using frames, but i'm not sure if the page will look exactly the way you want it. From what I understand, it is acceptable for you to change layout of the page. In that case frames as i said will do fine. But they won't work on (very) old browsers.

An 'iframe' element might look more like what you want, but it is IE specific (will not work on other browsers).

There is also another way that is server side. Hence, no need to worry about browser compatability. It is called SSI, Server Side Includes. And it has a very easy and HTML like syntax that enables you to include the output of a CGI program inside your webpage directly. You might then write a CGI program that outputs the HTML data that will display the form to the user when the page is simply viewed, and print the real output if the page data was instead submitted. However, I'm not sure about how is that exactly done. You might wanna search google for SSI or go directly and search in the Apache docs ( http://httpd.apache.com/ ).

BTW, if the form only does a specific and small job then its probablly much easier and more efficient to use a scripting language like PHP.

PHP is very similar to C in general concepts and has a very similar library of functions.

You might even get a full working piece of PHP code just by asking for it in the PHP section here in EE.
Avatar of GSD4ME

ASKER

Thanks. Am starting to implement the ideas on my web site but it may take a while!