Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > writing out data to a text file from a HTML form

Reply
Thread Tools

writing out data to a text file from a HTML form

 
 
Ron Smith
Guest
Posts: n/a
 
      08-07-2004
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.




 
Reply With Quote
 
 
 
 
Dave Patton
Guest
Posts: n/a
 
      08-07-2004
"Ron Smith" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> 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/
 
Reply With Quote
 
 
 
 
William Park
Guest
Posts: n/a
 
      08-07-2004
Ron Smith <(E-Mail Removed)> 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 <(E-Mail Removed)>
Open Geometry Consulting, Toronto, Canada
 
Reply With Quote
 
Ron Smith
Guest
Posts: n/a
 
      08-08-2004

"William Park" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Ron Smith <(E-Mail Removed)> 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 <(E-Mail Removed)>
> 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.


 
Reply With Quote
 
Hywel
Guest
Posts: n/a
 
      08-08-2004
In article <(E-Mail Removed)>, 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/
 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      08-08-2004
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

 
Reply With Quote
 
Ron Smith
Guest
Posts: n/a
 
      08-08-2004

"Toby Inkster" <(E-Mail Removed)> wrote in message
news(E-Mail Removed) .uk...
> 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


 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      08-08-2004
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

 
Reply With Quote
 
Ron Smith
Guest
Posts: n/a
 
      08-08-2004

"Toby Inkster" <(E-Mail Removed)> wrote in message
news(E-Mail Removed) .uk...
> 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.


 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      08-08-2004
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML File Upload using enctype=multipart/form-data in form? Matt Java 8 05-26-2012 07:40 AM
ASP.NET form action file - writing to text file icedragon ASP .Net 0 07-13-2010 01:48 PM
Any problems with writing the information into a file - Multi-users perform writing the same file at the same time ???? HNguyen ASP .Net 4 12-21-2004 01:53 PM
HTML File Upload using enctype=multipart/form-data in form? Matt HTML 1 10-12-2004 08:17 PM
Reading a DOS text file and writing out Mac jennyw Python 0 07-11-2003 04:57 PM



Advertisments