First of all, MySQL certainly has TABLES! but getting data into tables requires a little deliberate architecture and implementation.
Architecture:
What you have....
FrontPage form contains an 'action' tag that points to a peice of CGI.
What you need.
- Perl, most recent version.
- The Perl DBI module.
- The Perl DBD module for MySQL.
- A peice of CGI that knows what inputs are coming from your form.
- An installation of a MySQL server.
- An appropriate table structure in MySQL to contain your data.
The Perl DBI and DBD modules will enable you to connect to the mysql database. There is a lot to know about designing relational database schemas, but, hopefully, your data is very simple and you'll only need one table. Most web submitted data is very simple and the database design is
a no-brainer.
Assuming you have MySQL installed and the server is running, your code
might follow this flow.....
#!/usr/locall/bin/perl
PLAIN CGI STUFF
- load the CGI module
- load DBI
- start printing some HTML HEAD TITLE BODY TABLE stuff
- retrieve all inputs from your form - validate them as necessary
dates look like dates, numbers look like numbers, etc....
- once you're happy with the content that has been submitted
DATABASE STUFF
- connect to the database using the DBI/DBD stuff
- construct some appropriate SQL
- insert your data into the MySQL tables by executing the SQL
- catch success or failure information
- disconnect from the database
CLOSE OUT YOUR HTML
- report success or failure to browser
- close TABLE BODY HTML
What you need to learn:
- CGI with Perl - if you know a little perl, not to tough
- A little SQL - again, not to tough
- Depending on wether or not
you will be setting up your database and building the table structure, you may need to buy a book and do some reading to get that running. Also, there are a number of good toots on the web including at
Trying to learn all of this at the same time will be steep.
I would forget about messing with the database long enough to get some simple CGI stuff working. Then, neglect the CGI and figure out how to get a piece of plain command line Perl to talk to MySQL. Then, fold the database behaviors into your CGI stuff. None of this is terribly difficult, but, it will take some work to pick it up.
There are some good CGI tutorials on
under the tutorials link near the bottom of the page. Also, MySQL is well documented. You can see several examples in their documentation. Oh-Yeah, and of course, there is Tek-Tips.
I hope I have not been preaching to the choir.
'hope this helps
If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.