LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   save input from an online form to a file/database? (http://www.linuxquestions.org/questions/programming-9/save-input-from-an-online-form-to-a-file-database-785186/)

portia 01-27-2010 06:17 PM

save input from an online form to a file/database?
 
Browsing some websites I've found a code for online form where a user provides name, number, etc. Everything is created in html/javascript. I'm just wondering whether it's possible to collect this input and present it in a database form so that I'd be able to see who's provided data and all the details they entered.

Actually, it doesn't have to be a proper database (it would probably require php/mysql). It could be a weekly/monthly report (a text file) of people who provided details. The website is hosted by a third party company.
Thank you

This is an html bit:
Code:

<body id="main_body" >
 
    <img id="top" src="top.png" alt="">
    <div id="form_container">
 
        <h1><a>Untitled Form</a></h1>
        <form id="form_176031" class="appnitro"  method="post" action="">
                    <div class="form_description">
            <h2>Untitled Form</h2>
            <p>This is your form description. Click here to edit.</p>
        </div>                     
            <ul >
         
                    <li id="li_1" >
        <label class="description" for="element_1">Text </label>
        <div>
            <input id="element_1" name="element_1" class="element text medium" type="text" maxlength="255" value=""/>
        </div>
        </li>        <li id="li_2" >
        <label class="description" for="element_2">Number </label>
        <div>
            <input id="element_2" name="element_2" class="element text medium" type="text" maxlength="255" value=""/>
        </div>
        </li>        <li id="li_5" >
        <label class="description" for="element_5">Multiple Choice </label>
        <span>
            <input id="element_5_1" name="element_5" class="element radio" type="radio" value="1" />
<label class="choice" for="element_5_1">First option</label>
<input id="element_5_2" name="element_5" class="element radio" type="radio" value="2" />
<label class="choice" for="element_5_2">Second option</label>
<input id="element_5_3" name="element_5" class="element radio" type="radio" value="3" />
<label class="choice" for="element_5_3">Third option</label>

        </span>
        </li>        <li id="li_3" >
        <label class="description" for="element_3">Name </label>
        <span>
            <input id="element_3_1" name= "element_3_1" class="element text" maxlength="255" size="8" value=""/>
            <label>First</label>
        </span>
        <span>
            <input id="element_3_2" name= "element_3_2" class="element text" maxlength="255" size="14" value=""/>
            <label>Last</label>
        </span>
        </li>        <li id="li_4" >
        <label class="description" for="element_4">Date </label>
        <span>
            <input id="element_4_1" name="element_4_1" class="element text" size="2" maxlength="2" value="" type="text"> /
            <label for="element_4_1">MM</label>
        </span>
        <span>
            <input id="element_4_2" name="element_4_2" class="element text" size="2" maxlength="2" value="" type="text"> /
            <label for="element_4_2">DD</label>
        </span>
        <span>
            <input id="element_4_3" name="element_4_3" class="element text" size="4" maxlength="4" value="" type="text">
            <label for="element_4_3">YYYY</label>
        </span>
 
        <span id="calendar_4">
            <img id="cal_img_4" class="datepicker" src="calendar.gif" alt="Pick a date."> 
        </span>
        <script type="text/javascript">
            Calendar.setup({
            inputField    : "element_4_3",
            baseField    : "element_4",
            displayArea  : "calendar_4",
            button        : "cal_img_4",
            ifFormat    : "%B %e, %Y",
            onSelect    : selectDate
            });
        </script>
       
        </li>
         
                    <li class="buttons">
                <input type="hidden" name="form_id" value="176031" />
             
                <input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" />
        </li>
            </ul>
        </form>         
    </div>
    <img id="bottom" src="bottom.png" alt="">
    </body>

and js (I don't really know what they talk about here:)):
Code:

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};
if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};
while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);
return p}('3(7.X){7["R"+a]=a;7["z"+a]=6(){7["R"+a](7.1k)};7.X("1e",7["z"+a])}E{7.19("z",a,15)}2 j=H V();6 a(){2 e=q.1d("1a");3(e){o(e,"P");2 N=B(q,"*","14");3((e.12<=10)||(N=="")){c(e,"P",d)}}4=B(q,"*","1n");k(i=0;i<4.b;i++){3(4[i].F=="1g"||4[i].F=="1f"||4[i].F=="1c"){4[i].1b=6(){r();c(v.5.5,"f",d)};4[i].O=6(){r();c(v.5.5,"f",d)};j.D(j.b,0,4[i])}E{4[i].O=6(){r();c(v.5.5,"f",d)};4[i].18=6(){o(v.5.5,"f")}}}2 C=17.16.13();2 A=q.M("11");3(C.K("J")+1){c(A[0],"J",d)}3(C.K("I")+1){c(A[0],"I",d)}}6 r(){k(2 i=0;i<j.b;i++){o(j[i].5.5,"f")}}6 B(m,y,w){2 x=(y=="*"&&m.Y)?m.Y:m.M(y);2 G=H V();w=w.1m(/\\-/g,"\\\\-");2 L=H 1l("(^|\\\\s)"+w+"(\\\\s|$)");2 n;k(2 i=0;i<x.b;i++){n=x[i];3(L.1j(n.8)){G.1i(n)}}1h(G)}6 o(p,T){3(p.8){2 h=p.8.Z(" ");2 U=T.t();k(2 i=0;i<h.b;i++){3(h[i].t()==U){h.D(i,1);i--}}p.8=h.S(" ")}}6 c(l,u,Q){3(l.8){2 9=l.8.Z(" ");3(Q){2 W=u.t();k(2 i=0;i<9.b;i++){3(9[i].t()==W){9.D(i,1);i--}}}9[9.b]=u;l.8=9.S(" ")}E{l.8=u}}',62,86,'||var|if|elements|parentNode|function|window|className|_16|initialize|length|addClassName|true|_1|highlighted||_10||el_array|for|_13|_6|_c|removeClassName|_e|document|safari_reset||toUpperCase|_14|this|_8|_9|_7|load|_4|getElementsByClassName|_3|splice|else|type|_a|new|firefox|safari|indexOf|_b|getElementsByTagName|_2|onfocus|no_guidelines|_15|event_load|join|_f|_11|Array|_17|attachEvent|all|split|450|body|offsetWidth|toLowerCase|guidelines|false|userAgent|navigator|onblur|addEventListener|main_body|onclick|file|getElementById|onload|radio|checkbox|return|push|test|event|RegExp|replace|element'.split('|'),0,{}))

thanks

SethsdadtheLinuxer 01-28-2010 10:59 AM

checkout www.w3schools.com for better information on this. What you can(not) do is restricted by what type of access you have to the host.

portia 01-29-2010 10:54 PM

There's a form mailer script on the hosting account so for the time being I'll use it.
In the meantime, I'll need to learn such things.
I've got an ftp access to the account. I don't think ssh would work.
I really need to spend more (any!) time with javascript, php/mysql, etc.

theNbomr 01-30-2010 10:05 AM

The short answer is that the <form> element in the page defines a program (CGI) that will be invoked on the server when the browser user submits the form. HTTP & the web server will pass the form data to that program that will run on the server host. At that point, the CGI program can do whatever it wants with the data, including storing it on disk some way. Your question seems to hint that you want to do something with form data on the client side, but this is not the way HTML forms work.
--- rod.

portia 01-30-2010 10:22 AM

Quote:

Originally Posted by theNbomr (Post 3846102)
The short answer is that the <form> element in the page defines a program (CGI) that will be invoked on the server when the browser user submits the form. HTTP & the web server will pass the form data to that program that will run on the server host. At that point, the CGI program can do whatever it wants with the data, including storing it on disk some way. Your question seems to hint that you want to do something with form data on the client side, but this is not the way HTML forms work.
--- rod.

Not necessarily on the client side. I know it would have to store the data on the server side. Perhaps append each client registration details to a text file on the server host. I could then create an lftp script on my computer that would download it.

It's not going to be any online store. We're not relying on the website to do business. So the website has only informative purposes. The clients buy our products in normal shops. The idea is that if someone buys a product and registers it on our website, they will get an extended period of servicing. For that reason, I was asked to look into creating a simple online registration form which would provide us with data regarding clients that are eligible for extended servicing.

It could be that the owner of the website would log in to some sub-page created for this purpose and see the details of those clients. That would, however, be more complicated. As I said I need to really get down to learning those things.
An easier option would be that the details of each registration are emailed to him or me and we can actually create a database of such clients locally. Or even, as I mentioned before, if the registrations keep appending to a file on a server host I could manually grab it and work with sed/awk locally to achieve a desirable output.


All times are GMT -5. The time now is 07:19 PM.