+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14

Thread: Directing Form to File - Need Help

  1. #1
    Join Date
    Jan 2004
    Posts
    5

    Default

    Thank you very much for the free php script. It looks just like it is going to do just what I envisioned.

    I am a customer of OpenSourceHost and was referred to you by the Host Operator, Scott. I am setting up a photo gallery ([url=http://www.greensphotoimages.com])*and I am*new with*php, web publishing, etc. I would like to set up a visitor form that would*append each*visitor input to a record file*that I can import into Excel,*Access. or*a*MySQL database (it is on my site but I have never used it). I want to keep this fairly simple (for my sake).*So do you have any*suggestions in terms of what would be the simplest course of action and what modifications*I should make to the*formmail.php and*forms example file?

    Finally, in the Form Method tag, do I need to include a "ENCTYPE="text/plain" and your code shows "name="SampleForm",*do I replace it with a file name, or...?

    Your help is much appreciated. Thank you.

    Ron Green

  2. #2
    Join Date
    Dec 2003
    Posts
    3,901

    Default

    Hi Ron,

    Welcome to the FormMail forums.
    Finally, in the Form Method tag, do I need to include a "ENCTYPE="text/plain" and your code shows "name="SampleForm", do I replace it with a file name, or...?
    It's not critical, but yes, you can replace "SampleForm" with a name you want.* Just make sure you change it throughout the form.

    The ENCTYPE defaults to "application/x-www-form-urlencode" which is the correct encoding for submitting forms.* So, no, you don't want to change this.

    I would like to set up a visitor form that would append each visitor input to a record file that I can import into Excel, Access. or a MySQL database (it is on my site but I have never used it).
    FormMail already supports this feature. It can create a CSV (comma separated values) database (file) which you can import into your real database or spreadsheet.

    In FormMail, you need to set CSVDIR to a directory where you want to keep your CSV files.

    In your form you need to specify the following hidden fields:
    • csvfile (the name of the file you want to store values - this will be in CSVDIR) [/*]
    • csvcolumns (the "columns" you want in the CSV file - the fields from your form)[/*]
    There's quite a bit of documentation in formmail.php about this.

    The last step is to manually create your csvfile on your server and make it writable by your web server (rw-rw-rw-).

    Let me know if you need any more help with this.

    *

  3. #3
    Join Date
    Jan 2004
    Posts
    5

    Default

    Russell,

    Thank you :D*for the great response. At the risk of sounding like I have toys in the attic but no batteries to run them, I need to ask for some clarification. Here goes:

    You stated the following:

    "It can create a CSV (comma separated values) database (file) which you can import into your real database or spreadsheet.
    ... and
    The last step is to manually create your csvfile on your server and make it writable by your web server (rw-rw-rw-)."

    I am a little confused (actually, not so uncommon of a state for me according to my kids). Do I need to go into Excel and*set up a file with field names*across the columns and save it as a comma delimited file and then put it in its directory?*Or, does formmail.php actually create the file and it puts it in the directory I specify? I read through the file but I am just not getting it I guess!

    Ron


    *

  4. #4
    Join Date
    Dec 2003
    Posts
    3,901

    Default

    Hi Ron,

    No problem, here are the steps in detail:
    1. Create a directory on your server; if your server is Linux, then the directory will be something like this:
      /home/yourname/csvfiles
      You login to your server and create a directory called "csvfiles". [/*]
    2. Edit formmail.php and set CSVDIR to "/home/yourname/csvfiles". [/*]
    3. Login to your server and create a file called "/home/yourname/csvfiles/something.csv" [/*]
    4. Change "/home/yourname/csvfiles/something.csv" so that it has mode rw-rw-rw-; in other words, readable and writable by user, group, and world.* This is important because your web server generally runs as user "nobody" or "apache", not as you.* So, it needs to be able to write to this file. [/*]
    5. Next, in your HTML document with the form, create a hidden field called csvfile whose value is the name of the file you want to write to:
      Code:
      <input type="hidden" name="csvfile" value="something.csv">*
      Your form is thereby asking FormMail to write to the file "something.csv" in the directory specified by CSVDIR (in formmail.php: "/home/yourname/csvfiles"). [/*]
    6. Finally, again in your HTML document with the form, create another hidden field to specify what you want written in the CSV file:
      Code:
      <input type="hidden" name="csvcolumns" value="email,realname">
      (just list the field names in the "value" attribute).
    [/*]
    You can do steps 1-4 using SSH, Telnet, or FTP.* FTP is the easiest because you don't need to learn Linux commands.* And if your server is Windows, then FTP is probably the only way you can do this.

    Once your form is adding to the CSV file (something.csv) via formmail.php, then you can download that file using FTP and import it into Excel - that's the really simple part.

    So, to answer your last question: you create the file, but FormMail writes to the file for you. Excel, Access, etc. don't get involved until*you're ready to import the data into them.

    Hope that helps.**Post another question if you get stuck: make sure you tell me what you've managed to get done.

    Good luck.
    *


  5. #5
    Join Date
    Jan 2004
    Posts
    1

    Default

    re: Formmail.php, I also have the problem of formmail not updating the csv file. I have done all the steps:
    1: Made an orders.csv file in a new folder /orders from the root folder and made it -rw-rw-rw-.
    2:Set CSVDIR to /orders
    3:made a hidden field in my order form csvfile with orders.csv as the data;
    4:made a hidden field csvcolumns with data as name,address,etc exactly as directed.

    Everything works up to the csv file which never changes. I get the email, all the data, etc but what I need is the csv. What did I miss?

  6. #6
    Join Date
    Dec 2003
    Posts
    3,901

    Default

    Hi Dave,

    The pathing of folders is a little difficult to predict.

    Try this:
    *** 1. set CSVDIR to "orders" (get rid of the slash)
    *** 2. if that doesn't work, specify the full path name from the root
    ****** directory:
    **************** /home/your-name/public_html/orders

    Please post back and let us know how you go. :)

  7. #7
    Join Date
    Jan 2004
    Posts
    5

    Default

    Hi Russell,

    I got it to write to file (:D). I used*the*relative path "../csvfiles". I will admit that it*took me a number of tries, but it finally worked with the above. Also, in WS_FTP Pro,*the file didn't seem to change until I refreshed the directory. Then it went from 0 to 1k bytes. Hopefully, this might help davemiga. With that said, I do have 2*questions that I would appreciate your input on:

    1) Right now, after the*email is sent it goes to a confirmation screen and I have to use the browser's back arrow to get back. I would like to return to my home page were I initiated the request. How can I introduce a button that say "Home Page"?

    2) Can I post to both the CSV file and also include the info in the email I receive, or can you only have 1 post per form?

    Thanks for your help.

    Ron

  8. #8
    Join Date
    Dec 2003
    Posts
    3,901

    Default

    Hi Ron,

    That's good news....I'm glad you got it working.
    1) Right now, after the email is sent it goes to a confirmation screen and I have to use the browser's back arrow to get back. I would like to return to my home page were I initiated the request. How can I introduce a button that say "Home Page"?
    Yes, I recommend you create your own page and specify that page in the "good_url" field in your form.* You can then have whatever you like on there, including links to your home page.



    2) Can I post to both the CSV file and also include the info in the email I receive, or can you only have 1 post per form?
    Yes,*FormMail will write to your CSV file and send you email.* Just set up your form for both and it will happen.

    *

  9. #9
    Join Date
    Jan 2004
    Posts
    5

    Default

    Russell,

    Some help is implementing your feedback:

    1) I tried this in the form to get it to return to my webpage and it didn't work. Can you show me what I am doing wrong?

    <input type="hidden" name="good_url" value="http://www.greensphotoimages.com">

    2) I have added the "mesg" field to my form file and it does not transfer to the CSV file.*The name and email is*transferring. Again, what am I doing wrong?

    *** <input type="hidden" name="csvcolumns" value="email,realname,mesg">

    3) I noticed that the "mesg" comes through in the email between "Subject" and and the "REMOTE_HOST" lines. Where does this come from? I would like to see the*name and email as well. Can you help me on this?

    Thanks for all your help. This is really a big boost to getting this done and not having to become an expert overnight!

    Ron

  10. #10
    Join Date
    Jan 2004
    Posts
    5

    Default

    Russell.

    Regarding my last post, I was able to get all my questions answered and everything is working great so far. :D:D:D:D

    Any suggestions as to how to automatically fill in a date field*with today's date*on the form?

    Ron Green

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. File Uploads, Form Results
    By ScottR in forum Community Support
    Replies: 6
    Last Post: 29-Nov-2009, 01:42 AM
  2. Attaching a file when sending a form
    By thestampdad in forum Community Support
    Replies: 0
    Last Post: 20-Feb-2007, 01:23 AM
  3. CSV File - Automatically add all form fields
    By soulhost in forum Community Support
    Replies: 1
    Last Post: 08-Nov-2006, 10:39 PM
  4. Replies: 1
    Last Post: 23-Aug-2006, 10:32 PM
  5. Help trying to set up a form to email and send info to file
    By rridsdale in forum FormMail Subscription Support
    Replies: 1
    Last Post: 14-Jan-2004, 03:38 AM

Bookmarks

Posting Permissions

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