Capture input field data

Discussion in 'MySQL' started by hoshheid, Mar 26, 2009.

  1. #1
    Hi.

    I want to put two fields on my website for the user to input their name and their e-mail address.

    When they click Submit I want the data they entered to be captured by the database (MSAccess or Mysql?) - and listed like so:

    Name E-mail
    John
    Simon
    Ben


    Does anyone know if any open source script does this, or can somebody create this for me - I don't mind paying, let me know your rate. The input fields will be on a html page and the database can be of any type as long as it runs on a Linux server.


    Thanks
     
    hoshheid, Mar 26, 2009 IP
  2. risoknop

    risoknop Peon

    Messages:
    914
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You need a server side language for this, such as PHP, Ruby, ASP.NET etc. It's pretty easy to do.
     
    risoknop, Mar 26, 2009 IP
  3. hoshheid

    hoshheid Banned

    Messages:
    116
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks


    Unfortunately the system I use for my website is all html files. I have no choice whatsoever - it has to be html.

    I cannot change the pages to php or asp.

    Is it not possible to do this using HTML and a database?
     
    hoshheid, Mar 26, 2009 IP
  4. risoknop

    risoknop Peon

    Messages:
    914
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #4
    For example - a MySQL table could look like this:

    
    CREATE TABLE clients (
        id INT NOT NULL AUTO_INCREMENT,
        name VARCHAR(255) NOT NULL,
        email VARCHAR(255) NOT NULL,
        PRIMARY KEY (id)
    ) ENGINE = MYISAM;
    
    Code (markup):
    And PHP:

    
    if (isset($_POST['your_form_name'])) {
        // name
        $name = $_POST['name'];
        // email
        $email = $_POST['email'];
        try {
            // username
            $username = 'root';
            // password
            $password = 'password';
            $dbh = new PDO("mysql:host=localhost;dbname=dbname", $username, $password);
            $sth = $dbh->prepare('INSERT INTO clients (name, email) VALUES (?, ?)');
            $sth->execute(array($name, $email));
            $count = $sth->rowCount();
        } catch(PDOException $e) {
            echo $e->getMessage();
        }
    }
    
    PHP:
    Of course there is almost no validation above, so you should add some before using it.
     
    risoknop, Mar 26, 2009 IP
  5. risoknop

    risoknop Peon

    Messages:
    914
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Well, I don't know if that's possible, probably not :( You certainly need something server side to insert the values into the database, at least CGI or something.
     
    risoknop, Mar 26, 2009 IP
  6. risoknop

    risoknop Peon

    Messages:
    914
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Are there any special reasons you are using flat html files? The easiest solution would be to change that - just rename all html files to php and install PHP interpreter on your server.

    You could also probably configure PHP to work with files with html extensions as if they were PHP but you will still need to have the PHP installed on your server.
     
    risoknop, Mar 26, 2009 IP
  7. hoshheid

    hoshheid Banned

    Messages:
    116
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    A) Because the site ranks very highly in search engines and turns over £1m a year - we cannot afford to change file extentions and risk losing the search engine rankings.

    B) I have a dedicated server with php installed - but my site is HTML and I cannot change this.

    C) My site uses a combination of html and cgi (perl scripts) - what can be done with html/cgi/perl?
     
    hoshheid, Mar 26, 2009 IP
  8. risoknop

    risoknop Peon

    Messages:
    914
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I am not expert with cgi/perl so you whould wait for someone with more experience to reply.

    However, regarding SEO reason - this can be achieved by rewriting URLs. All your files can be php/asp anything but they would be rewritten on fly by web server so they would appear as plain html files to search engines. That way you shouldn't loose rankings.

    http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
     
    risoknop, Mar 26, 2009 IP
  9. hoshheid

    hoshheid Banned

    Messages:
    116
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Sounds very 'on the edge' to me, I would rather wait and see if somebody could provide a cgi/perl integration.

    Thanks for your help!
     
    hoshheid, Mar 26, 2009 IP
  10. plog

    plog Peon

    Messages:
    298
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #10
    This can be done and I have done it multiple times. What you do is create a form in an .html page that submits to a .php file, the .php file does everything it needs to then redirects the user to another .html file. The user, nor any search engine spiders ever see the .php file.

    If all you are capturing is email address I can have this up and running in 48 hours for between $50-$100. That includes database creation, an admin page to retrieve data and setting up the .html form to submit properly and the .php file to process it all. The price range reflects various options about the admin area and redirection pages.

     
    plog, Mar 26, 2009 IP
  11. plog

    plog Peon

    Messages:
    298
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #11
    This can be done and I have done it multiple times. What you do is create a form in an .html page that submits to a .php file, the .php file does everything it needs to then redirects the user to another .html file. The user, nor any search engine spiders ever see the .php file.

    If all you are capturing is email address I can have this up and running in 48 hours for between $50-$100. That includes database creation, an admin page to retrieve data and setting up the .html form to submit properly and the .php file to process it all. The price range reflects various options about the admin area and redirection pages.

     
    plog, Mar 26, 2009 IP
  12. ergtron

    ergtron Peon

    Messages:
    58
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Plog is right and the price is ok since he'll do a simple admin area.
     
    ergtron, Mar 26, 2009 IP