Immediate form problem

Discussion in 'Databases' started by igneous, Jun 7, 2006.

  1. #1
    I started a new site recently, and it include a short form, which only has 5 fields. I am using it with dreamhost, so I just used formmail to process the form, as I thought it would be easy to take the results from my email to an excel file. Well, I ended up getting about 1500 people to fill out the form in the past couple days, and have too much to process. I basically want to find the simplest way to take form results and just put them into a database. I want it so I can take the results off the database and store them easily on excel. I just started looking at phpFormGenerator, but Im not sure if this is my easiest option. Any quick suggestions? thanks :)
     
    igneous, Jun 7, 2006 IP
  2. sketch

    sketch Well-Known Member

    Messages:
    898
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    148
    #2
    If I'm reading this correctly, you want to save your form submissions into a database so you can export the database to an Excel file? I would just save them straight to the Excel file.

    You can either whip up some quick code to save a simple CSV (comma-separated values) file which you can open in Excel or look around for web scripts that'll export full-out Excel files. You can then have your script append every new submission to the end or beginning of the file.
     
    sketch, Jun 7, 2006 IP
  3. igneous

    igneous Peon

    Messages:
    106
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I was just looking at my database stuff, and dreamhost provides me with phpmyadmin, which from what I can see can export the database into excel, word, csv, or xml. So I guess that should be all set. I just am not sure how to create a form so it puts it into this database.
     
    igneous, Jun 7, 2006 IP
  4. igneous

    igneous Peon

    Messages:
    106
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think I actually figured it out. Heres my PHP code that my form posts to, the only thing i am not sure how to do is make the form to go to a thanks page or an imcomplete page if they missed a field.
    <?php
    @extract($_POST);
    if(is_writable('emails.csv'))
    {
    $fp = fopen('emails.csv','a');
    $content = "$firstname,$lastname,$email,$zip,$conf\n";
    fwrite($fp,$content);
    fclose($fp);
    }
    else
    {
    echo'File is not writable';
    }
    ?>
     
    igneous, Jun 7, 2006 IP
  5. sketch

    sketch Well-Known Member

    Messages:
    898
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    148
    #5
    To have it go to a page after executing code, use header("Location: domain.com/thanks.html"); and make sure to exit; the line after to show the correct URL (unless you don't want that :) ). Or simply use the echo command to output your message.
     
    sketch, Jun 7, 2006 IP
  6. igneous

    igneous Peon

    Messages:
    106
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks, I'm not quite sure where that fits in the code though. I've tried a bunch of different spots and I keep getting errors such as:
    Warning: Cannot modify header information - headers already sent by...
     
    igneous, Jun 7, 2006 IP