Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2013
    Posts
    23
    Thanks
    4
    Thanked 0 Times in 0 Posts

    cgi to dump xml data from form input field

    Hi All,

    I am trying to write a shell script which takes parse the web form find the input field and dump the data of that field into one xml file. The form looks like,

    Code:
    <input type="button" id="btnSave" value="Save" onclick="saveXmlData()"/>		
    <form name="submitForm" action="./saveData.cgi" method="get">
    	<input type="hidden" name="xmldata" />
    </form>
    At the end the cgi should return a html saying that "Data saved."

    I have never written cgi. I would appreciate if you can guide me resolvethis or point me out some article, sample or other link.

    Thanks,
    Jdp

  • #2
    New Coder
    Join Date
    May 2013
    Posts
    23
    Thanks
    4
    Thanked 0 Times in 0 Posts
    This is how I did it,

    Code:
    #!/bin/sh
    
    if [ "$REQUEST_METHOD" = "POST" ]; then
        if [ "$CONTENT_LENGTH" -gt 0 ]; then
            read -n $CONTENT_LENGTH POST_DATA <&0
        fi
    fi
    
    echo $POST_DATA > settings.xml
    
    echo "Content-type: text/html"
    echo ""
    echo "<html><head><title>Saved</title></head><body>"
    echo "Data saved to SETTINGS.XML<br/>"
    echo "</body></html>"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •