writing out data to a text file from a HTML form

Discussion in 'HTML' started by Ron Smith, Aug 7, 2004.

  1. Ron Smith

    Ron Smith Guest

    What I want to do is create a HTML form that allows the user to enter data
    into about 10 fields, and then based on the entered data, writes out data
    strings to a text file. I am attempting to create a form for entering
    simple rectangle CAD data via a HTML form, which will be written to a text
    file, and then imported into a CAD program.

    The form would contain prompt boxes for things like length, width, radius
    size, step/repeat, etc. When the user hits the "SUBMIT" button, the data
    strings would be written out to the filename the user specified. Below is
    an example of data strings to be ouputted. Variables are &L, &W, &R,
    &STEPX, &STEPY, &XN, &YN.

    FRO 0 0 BY &L 0 ATT 1 POI 2
    BY 0 &W ATT 1 POI 2
    BY -&L,0 ATT 1 POI 2
    TO 0 0 POI 2
    JOI EXT 1 2 BLE &R
    JOI EXT 2 3 BLE &R
    JOI EXT 3 4 BLE &R
    JOI EXT 4 1 BLE &R
    TRY;SEC LAYOUT;REC;LAYOUT;YRT
    SUB A POS 0 0 ATT 0;FILE A INT
    MER A TO A
    TRY;COP 1 BY &STEPX 0 TIM &XN-1;REC;YRT
    TRY;COP .. BY 0 &STEPY TIM &YN-1;REC;YRT
    --------------------------------------------------------

    Any help on a source of example code would be appreciated.
     
    Ron Smith, Aug 7, 2004
    #1
    1. Advertising

  2. Ron Smith

    Dave Patton Guest

    "Ron Smith" <> wrote in
    news::

    > What I want to do is create a HTML form that allows the user to enter
    > data into about 10 fields, and then based on the entered data, writes
    > out data strings to a text file.


    Make the target of the form be a PHP script that takes the
    form inputs and writes the text file.

    --
    Dave Patton
    Canadian Coordinator, Degree Confluence Project
    http://www.confluence.org/
    My website: http://members.shaw.ca/davepatton/
     
    Dave Patton, Aug 8, 2004
    #2
    1. Advertising

  3. Ron Smith

    William Park Guest

    Ron Smith <> wrote:
    > What I want to do is create a HTML form that allows the user to enter data
    > into about 10 fields, and then based on the entered data, writes out data
    > strings to a text file. I am attempting to create a form for entering
    > simple rectangle CAD data via a HTML form, which will be written to a text
    > file, and then imported into a CAD program.
    >
    > The form would contain prompt boxes for things like length, width, radius
    > size, step/repeat, etc. When the user hits the "SUBMIT" button, the data
    > strings would be written out to the filename the user specified. Below is
    > an example of data strings to be ouputted. Variables are &L, &W, &R,
    > &STEPX, &STEPY, &XN, &YN.
    >
    > FRO 0 0 BY &L 0 ATT 1 POI 2
    > BY 0 &W ATT 1 POI 2
    > BY -&L,0 ATT 1 POI 2
    > TO 0 0 POI 2
    > JOI EXT 1 2 BLE &R
    > JOI EXT 2 3 BLE &R
    > JOI EXT 3 4 BLE &R
    > JOI EXT 4 1 BLE &R
    > TRY;SEC LAYOUT;REC;LAYOUT;YRT
    > SUB A POS 0 0 ATT 0;FILE A INT
    > MER A TO A
    > TRY;COP 1 BY &STEPX 0 TIM &XN-1;REC;YRT
    > TRY;COP .. BY 0 &STEPY TIM &YN-1;REC;YRT
    > --------------------------------------------------------
    >
    > Any help on a source of example code would be appreciated.


    I don't understand. User types 'abc' into a form box, and you print it
    out to a file. What is your question, exactly?

    If this is question about how to print inside CGI, then take a look at
    sample CGI script found on your machine or on Internet.

    --
    William Park <>
    Open Geometry Consulting, Toronto, Canada
     
    William Park, Aug 8, 2004
    #3
  4. Ron Smith

    Ron Smith Guest

    "William Park" <> wrote in message
    news:...
    > Ron Smith <> wrote:
    > > What I want to do is create a HTML form that allows the user to enter

    data
    > > into about 10 fields, and then based on the entered data, writes out

    data
    > > strings to a text file. I am attempting to create a form for entering
    > > simple rectangle CAD data via a HTML form, which will be written to a

    text
    > > file, and then imported into a CAD program.
    > >
    > > The form would contain prompt boxes for things like length, width,

    radius
    > > size, step/repeat, etc. When the user hits the "SUBMIT" button, the

    data
    > > strings would be written out to the filename the user specified. Below

    is
    > > an example of data strings to be ouputted. Variables are &L, &W, &R,
    > > &STEPX, &STEPY, &XN, &YN.
    > >
    > > FRO 0 0 BY &L 0 ATT 1 POI 2
    > > BY 0 &W ATT 1 POI 2
    > > BY -&L,0 ATT 1 POI 2
    > > TO 0 0 POI 2
    > > JOI EXT 1 2 BLE &R
    > > JOI EXT 2 3 BLE &R
    > > JOI EXT 3 4 BLE &R
    > > JOI EXT 4 1 BLE &R
    > > TRY;SEC LAYOUT;REC;LAYOUT;YRT
    > > SUB A POS 0 0 ATT 0;FILE A INT
    > > MER A TO A
    > > TRY;COP 1 BY &STEPX 0 TIM &XN-1;REC;YRT
    > > TRY;COP .. BY 0 &STEPY TIM &YN-1;REC;YRT
    > > --------------------------------------------------------
    > >
    > > Any help on a source of example code would be appreciated.

    >
    > I don't understand. User types 'abc' into a form box, and you print it
    > out to a file. What is your question, exactly?
    >
    > If this is question about how to print inside CGI, then take a look at
    > sample CGI script found on your machine or on Internet.
    >
    > --
    > William Park <>
    > Open Geometry Consulting, Toronto, Canada


    Sorry for the confusion. User types in values (numbers) for length, width,
    and radius size of a rectangle, how many they want, and the step/repeat
    value of the rectangle matrix. The code (resulting text file) which you
    highlighted is created from the data inputted by the user, and later, this
    text file is imported into a CAD program.
     
    Ron Smith, Aug 8, 2004
    #4
  5. Ron Smith

    Hywel Guest

    In article <>, Ron Smith says...
    > What I want to do is create a HTML form that allows the user to enter data
    > into about 10 fields, and then based on the entered data, writes out data
    > strings to a text file. I am attempting to create a form for entering
    > simple rectangle CAD data via a HTML form, which will be written to a text
    > file, and then imported into a CAD program.


    What server-side processing do you have? ASP? CGI? PHP?

    --
    Hywel

    http://sponsorhywel.org.uk/
     
    Hywel, Aug 8, 2004
    #5
  6. Ron Smith

    Toby Inkster Guest

    Toby Inkster, Aug 8, 2004
    #6
  7. Ron Smith

    Ron Smith Guest

    "Toby Inkster" <> wrote in message
    news:p...
    > Ron Smith wrote:
    >
    > > What I want to do is create a HTML form that allows the user to enter

    data
    > > into about 10 fields, and then based on the entered data, writes out

    data
    > > strings to a text file.

    >
    > http://examples.tobyinkster.co.uk/cad/form
    > http://examples.tobyinkster.co.uk/cad/handler-src
    >
    > --
    > Toby A Inkster BSc (Hons) ARCS
    > Contact Me ~ http://tobyinkster.co.uk/contact
    > Now Playing ~ ./no_doubt/dont_speak.ogg
    >

    Toby,

    Thanks a lot. That is exactly what I was looking for.

    Ron
     
    Ron Smith, Aug 8, 2004
    #7
  8. Ron Smith

    Toby Inkster Guest

    Ron Smith wrote:
    > Toby Inkster wrote:
    >
    >> http://examples.tobyinkster.co.uk/cad/form
    >> http://examples.tobyinkster.co.uk/cad/handler-src

    >
    > Thanks a lot. That is exactly what I was looking for.


    No worries.

    I did forget to mention one particular gotcha though -- your web host has
    to support server-side scripting in some language. (I used PHP in the
    example, but doing the same thing in Perl, Python, JSP or ASP would be
    smiple.) Nowadays most hosts do support some kind of server-side scripting
    (except most free hosting packages).

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Now Playing ~ ./warm_jets/future_signs/07_autopia.ogg
     
    Toby Inkster, Aug 8, 2004
    #8
  9. Ron Smith

    Ron Smith Guest

    "Toby Inkster" <> wrote in message
    news:p...
    > Ron Smith wrote:
    > > Toby Inkster wrote:
    > >
    > >> http://examples.tobyinkster.co.uk/cad/form
    > >> http://examples.tobyinkster.co.uk/cad/handler-src

    > >
    > > Thanks a lot. That is exactly what I was looking for.

    >
    > No worries.
    >
    > I did forget to mention one particular gotcha though -- your web host has
    > to support server-side scripting in some language. (I used PHP in the
    > example, but doing the same thing in Perl, Python, JSP or ASP would be
    > smiple.) Nowadays most hosts do support some kind of server-side scripting
    > (except most free hosting packages).
    >
    > --
    > Toby A Inkster BSc (Hons) ARCS
    > Contact Me ~ http://tobyinkster.co.uk/contact
    > Now Playing ~ ./warm_jets/future_signs/07_autopia.ogg
    >

    I downloaded and installed an Apache webserver, with PHP. Being new to
    both, I am having trouble figuring out how to associate the two files (HTML
    form screen and PHP file), in regards to file location and filename. ie.
    Where do I place them on my local server so Apache can find them? I
    couldn't figure out how you did it, but I assume the hander-src file has a
    ..PHP extension.
     
    Ron Smith, Aug 8, 2004
    #9
  10. Ron Smith

    Toby Inkster Guest

    Ron Smith wrote:
    > Toby Inkster wrote:
    >
    >> http://examples.tobyinkster.co.uk/cad/form
    >> http://examples.tobyinkster.co.uk/cad/handler-src
    >>
    >> I did forget to mention one particular gotcha though -- your web host has
    >> to support server-side scripting in some language.

    >
    > I downloaded and installed an Apache webserver, with PHP.


    You do realise that PHP needs to be installed on your web server, not on
    your desktop computer? (Though for some people, like me, your desktop
    computer *is* your web server!)

    > Being new to both, I am having trouble figuring out how to associate the
    > two files (HTML form screen and PHP file), in regards to file location
    > and filename. ie. Where do I place them on my local server so Apache
    > can find them? I couldn't figure out how you did it, but I assume the
    > hander-src file has a .PHP extension.


    This file <http://examples.tobyinkster.co.uk/cad/handler-src> is a red
    herring -- the real engine is at
    <http://examples.tobyinkster.co.uk/cad/handler> but you won't be able to
    see it, because the actual PHP code that does the work never gets sent to
    the browser. That's why I put a highlighted *copy* of the source code at
    <http://examples.tobyinkster.co.uk/cad/handler-src>

    The form's "action" attribute should point to the handler.php file. The
    handler.php file should contain this code:

    <?php
    header("Content-Type: text/plain");

    $L = $_GET['L'];
    $W = $_GET['W'];
    $R = $_GET['R'];
    $STEPX = $_GET['STEPX'];
    $STEPY = $_GET['STEPY'];
    $XN = $_GET['XN'];
    $YN = $_GET['YN'];
    ?>
    FRO 0 0 BY <?= $L ?> 0 ATT 1 POI 2
    BY 0 <?= $W ?> ATT 1 POI 2
    BY -<?= $L ?>,0 ATT 1 POI 2
    TO 0 0 POI 2
    JOI EXT 1 2 BLE <?= $R ?>
    JOI EXT 2 3 BLE <?= $R ?>
    JOI EXT 3 4 BLE <?= $R ?>
    JOI EXT 4 1 BLE <?= $R ?>
    TRY;SEC LAYOUT;REC;LAYOUT;YRT
    SUB A POS 0 0 ATT 0;FILE A INT
    MER A TO A
    TRY;COP 1 BY <?= $STEPX ?> 0 TIM <?= $XN ?>-1;REC;YRT
    TRY;COP .. BY 0 <?= $STEPY ?> TIM <?= $YN ?>-1;REC;YRT

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Now Playing ~ ./billy_joel/new_york_state_of_mind.ogg
     
    Toby Inkster, Aug 8, 2004
    #10
  11. Ron Smith

    Ron Smith Guest

    "Toby Inkster" <> wrote in message
    news:p...
    > Ron Smith wrote:
    > > Toby Inkster wrote:
    > >
    > >> http://examples.tobyinkster.co.uk/cad/form
    > >> http://examples.tobyinkster.co.uk/cad/handler-src
    > >>
    > >> I did forget to mention one particular gotcha though -- your web host

    has
    > >> to support server-side scripting in some language.

    > >
    > > I downloaded and installed an Apache webserver, with PHP.

    >
    > You do realise that PHP needs to be installed on your web server, not on
    > your desktop computer? (Though for some people, like me, your desktop
    > computer *is* your web server!)


    I have a program called XAMPP for Windows (webserver) with PHP - both are
    running as a local host on my desktop. I need to figure out how to run the
    HTML file through XAMPP. XAMPP has a status screen that tells me it is
    running, and PHP can be interpreted.
     
    Ron Smith, Aug 9, 2004
    #11
  12. Ron Smith

    Sam Hughes Guest

    "Ron Smith" <> wrote in
    news::

    >
    > "Toby Inkster" <> wrote in message
    > news:p...
    >> Ron Smith wrote:
    >> > Toby Inkster wrote:
    >> >
    >> >> http://examples.tobyinkster.co.uk/cad/form
    >> >> http://examples.tobyinkster.co.uk/cad/handler-src
    >> >>
    >> >> I did forget to mention one particular gotcha though -- your web
    >> >> host

    > has
    >> >> to support server-side scripting in some language.
    >> >
    >> > I downloaded and installed an Apache webserver, with PHP.

    >>
    >> You do realise that PHP needs to be installed on your web server, not
    >> on your desktop computer? (Though for some people, like me, your
    >> desktop computer *is* your web server!)

    >
    > I have a program called XAMPP for Windows (webserver) with PHP - both
    > are running as a local host on my desktop. I need to figure out how
    > to run the HTML file through XAMPP. XAMPP has a status screen that
    > tells me it is running, and PHP can be interpreted.


    In your address bar, type in "localhost" or "127.0.0.1".



    --
    In a room with thirty-seven people, never have everybody shake each
    other's hand.
     
    Sam Hughes, Aug 9, 2004
    #12
  13. Ron Smith

    Ron Smith Guest

    "Sam Hughes" <> wrote in message
    news:Xns953FC72E6360Ehughesrpiedu@130.133.1.4...
    > "Ron Smith" <> wrote in
    > news::
    >
    > >
    > > "Toby Inkster" <> wrote in message
    > > news:p...
    > >> Ron Smith wrote:
    > >> > Toby Inkster wrote:
    > >> >
    > >> >> http://examples.tobyinkster.co.uk/cad/form
    > >> >> http://examples.tobyinkster.co.uk/cad/handler-src
    > >> >>
    > >> >> I did forget to mention one particular gotcha though -- your web
    > >> >> host

    > > has
    > >> >> to support server-side scripting in some language.
    > >> >
    > >> > I downloaded and installed an Apache webserver, with PHP.
    > >>
    > >> You do realise that PHP needs to be installed on your web server, not
    > >> on your desktop computer? (Though for some people, like me, your
    > >> desktop computer *is* your web server!)

    > >
    > > I have a program called XAMPP for Windows (webserver) with PHP - both
    > > are running as a local host on my desktop. I need to figure out how
    > > to run the HTML file through XAMPP. XAMPP has a status screen that
    > > tells me it is running, and PHP can be interpreted.

    >
    > In your address bar, type in "localhost" or "127.0.0.1".
    >

    When I do that, I am able to run XAMPP as a local host. I can input my
    values in the form, but the values are not being interpreted by the PHP
    file. I guess I am confused with how PHP files are called from an HTML
    file. I couldn't find any reference to the handler-src PHP file in the file
    form.html
     
    Ron Smith, Aug 9, 2004
    #13
  14. Ron Smith

    Toby Inkster Guest

    Ron Smith wrote:

    > I couldn't find any reference to the handler-src PHP file in the file
    > form.html


    As I said...

    | This file <http://examples.tobyinkster.co.uk/cad/handler-src> is a red
    | herring -- the real engine is at
    | <http://examples.tobyinkster.co.uk/cad/handler> but you won't be able to
    | see it, because the actual PHP code that does the work never gets sent
    | to the browser. That's why I put a highlighted *copy* of the source code
    | at <http://examples.tobyinkster.co.uk/cad/handler-src>
    |
    | The form's "action" attribute should point to the handler.php file.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Aug 9, 2004
    #14
  15. Ron Smith

    Ron Smith Guest

    "Toby Inkster" <> wrote in message
    news:p...
    > Ron Smith wrote:
    >
    > > I couldn't find any reference to the handler-src PHP file in the file
    > > form.html

    >
    > As I said...
    >
    > | This file <http://examples.tobyinkster.co.uk/cad/handler-src> is a red
    > | herring -- the real engine is at
    > | <http://examples.tobyinkster.co.uk/cad/handler> but you won't be able to
    > | see it, because the actual PHP code that does the work never gets sent
    > | to the browser. That's why I put a highlighted *copy* of the source code
    > | at <http://examples.tobyinkster.co.uk/cad/handler-src>
    > |
    > | The form's "action" attribute should point to the handler.php file.
    >
    > --
    > Toby A Inkster BSc (Hons) ARCS
    > Contact Me ~ http://tobyinkster.co.uk/contact
    >

    Thanks Toby. I got confused on the handler-src filename.
     
    Ron Smith, Aug 9, 2004
    #15
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. HNguyen
    Replies:
    4
    Views:
    2,429
    HNguyen
    Dec 21, 2004
  2. jennyw
    Replies:
    0
    Views:
    329
    jennyw
    Jul 11, 2003
  3. Skip Montanaro
    Replies:
    0
    Views:
    433
    Skip Montanaro
    Jul 11, 2003
  4. icedragon
    Replies:
    0
    Views:
    654
    icedragon
    Jul 13, 2010
  5. Ron Smith

    writing out to a text file with javascript

    Ron Smith, Aug 7, 2004, in forum: Javascript
    Replies:
    3
    Views:
    109
    MikeB
    Aug 7, 2004
Loading...

Share This Page