Skip to content
General Revolution Evolution Add-ons International
Login | Register | MODX.com
MODX Open Source Content Management System, Framework, Platform and More.
Find a Partner | Hosts + SaaS | Jobs | Donate
  • RegisterSign Up with the MODX Community
  • LoginUse Your MODX.com Account
  • MODX Community Forums
  • Add-ons
  • Forms, Form Processing & Anti-Spam
  •  
  • <
  • 1
  • 2
  • >
  • form add on that sends data to .csv#

  • 31191
    31
    perusing forums is where my comp sci degree got me.

    v2theg Reply #1, 1 year, 1 month ago

    Reply
    • Link to this post#1
    Do of the contact form add-ons for Revolution allow you to dump the data from a user-filled form to a text or .csv file?


  • 3749
    11,683
    PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!

    MODx info for everyone: http://bobsguides.com/MODx.html

    BobRay Reply #2, 1 year, 1 month ago

    Reply
    • Link to this post#2
    At this point, it would take a custom hook snippet for FormIt, but a fairly simple one.


  • 31191
    31
    perusing forums is where my comp sci degree got me.

    v2theg Reply #3, 1 year, 1 month ago

    Reply
    • Link to this post#3
    Thanks. I thought I'd post what I used to do this for anyone with future questions on it. As you said, pretty simple! This custom hook runs after the email hook and before the redirect.

    <?php
    $fp = fopen("/path/to/file/filename.csv", 'a');
    
    fputcsv($fp, array(
      $hook->getValue('first_name'), 
      $hook->getValue('last_name'),  
      $hook->getValue('email'), 
    ));
    
    fclose($fp);
    return true;


    This page helped http://rtfm.modx.com/display/ADDON/FormIt.Hooks#FormIt.Hooks-CustomHooks


  • 3749
    11,683
    PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!

    MODx info for everyone: http://bobsguides.com/MODx.html

    BobRay Reply #4, 1 year, 1 month ago

    Reply
    • Link to this post#4
    Glad you got it sorted. Thanks for reporting back.


  • 28099
    16

    SpaceCity Reply #5, 11 months ago

    Reply
    • Link to this post#5
    I am trying to get formIt to write to CSV as well. I found this post and tried to implement it, but nothing seems to be happening.

    I took the above code and only changed the fields, saved it as a Snippet called "FormItCSV" and put it in the formIt folder under Snippets.

    Then I added to the list of hooks like so:
    &hooks=`spam,email,FormItCSV,redirect`


    When I submit the form it does everything BUT write to CSV. I'm not even certain that it is loading the snippet. If the snippet failed then it would not have redirected, right?

    Has anyone had any success getting formIt to write to CSV?


  • 31191
    31
    perusing forums is where my comp sci degree got me.

    v2theg Reply #6, 11 months ago

    Reply
    • Link to this post#6
    Is your csv file on the server writable? It should be 646 at least or 666. Also, check your path to the csv, it should the absolute path to the server.

    Something like:

    var/www/domain.com/filename.csv


  • 28099
    16

    SpaceCity Reply #7, 11 months ago

    Reply
    • Link to this post#7
    Ok, turns out there is a nice component that does all this:
    http://modx.com/extras/package/ditsformsaver

    Don't know why this never turned up in my hours of Googling, but am grateful to have found it. Works great....


  • 36704
    34

    alyainec Reply #8, 3 months, 2 weeks ago

    Reply
    • Link to this post#8
    Hi v2theg,

    i tried to use your sample snippets but it not works on me,
    Nothing saves on csv file.


    here is my formit



    <h2>Contact Form</h2>

    [[!+fi.error_message:notempty=`<p></p>`]]




    And here is your snippets
    <?php
    $fp = fopen("assets/upload/filename.csv", 'a');

    fputcsv($fp, array(
    $hook->getValue('first_name'),
    $hook->getValue('last_name'),
    $hook->getValue('email'),
    ));

    fclose($fp);
    return true;

    The permission on that folder is 2775

    Did i miss something? Any help?

    Thanks


  • 36704
    34

    alyainec Reply #9, 3 months, 1 week ago

    Reply
    • Link to this post#9
    Hi v2theg

    I have found my mistake that was on my path settings was wrong and put the right path and it's working right now.
    All of the data input in user's registration form was automatically save into my csv file.

    But i have another question in this snippets, is there anyway to get the date & time stamp?
    Can you teach me how to insert that inside this snippets?

    Bobyray, please help me because my knowledge in programming was not good.

    Thanks very much


  • 3749
    11,683
    PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!

    MODx info for everyone: http://bobsguides.com/MODx.html

    BobRay Reply #10, 3 months, 1 week ago

    Reply
    • Link to this post#10
    If you want to save the date/time to the DB, you probably want the PHP time() function:

    http://php.net/manual/en/function.time.php

    You can format it when you retrieve it with strftime():

    http://www.php.net/manual/en/function.strftime.php

    If, for some reason, you want to save it or display it in human-readable form, you can use the date() function:

    http://php.net/manual/en/function.date.php
    What is it that you want to do with the date/time?



    ---------------------------------------------------------------------------------------------------------------
    PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
    MODx info for everyone: http://bobsguides.com/modx.html


  • <
  • 1
  • 2
  • >



Actions

Login to Post

Other Support Options

To file a bug or make a feature request visit our issue tracker, or you can also purchase commercial support.

Love MODX?

If you build sites for a living with MODX or just love using it, why not give back?

Information

Posted in this thread:
BobRay, SpaceCity, alyainec, v2theg

 
Back to Top

MODX Global HQ

1333 N Stemmons Fwy, Ste 110
Dallas, TX 75207
United States

+1 (469) 777-MODX (6639)

The MODX Company

  • Contact
  • Media Center
  • Careers at MODX
  • Wall of Fame
  • The MODX Blog

Sponsors

SoftLayer Firehost: Secure Cloud Hosting

Stay Connected

Read our previous email newsletters.

Twitter Facebook Google+ LinkedIn github Feeds

Privacy Policy | Terms of Service | Pixels by AKTA Web Studio© 2005-2012 MODX. All rights reserved. Trademark Policy