Click to See Complete Forum and Search --> : Dreamweaver and MySQL connection through PERL


cuau
09-28-2009, 11:41 PM
Hi, I am a newbie in Dreamweaver and MySQL stuff, perl etc.

I use Dreamweaver CS3. I have recently created a web form, the typical "contat us" form and I was able to set it up through a CGI script, with hidden buttons that runs the script which was provided by the server. This script sends the contact information to to a specific email in the body of the email. Currently that works, but...

Instead of doing that, I want that information to be transmitted to a MySQL database and table that I also have created using PHPmyAdmin.

1st QUESTION: How do I transfer the data to the MySQL table using CGI Perl?

2nd QUESTION: the other problem I have is that I am not even sure if the script below is Perl code, and if Dreamweaver supports Perl.

3rd QUESTION: if it is supported by Dreamweaver, would I just copy/paste the script into the code mode?

I can understand what I am supposed to do by cutting/pasting and replacing, but I am not even sure if its something I should be trying and if its compatible, so I dont want to waste time. PLEASE HELP!!!

SCRIPT PROVIDED BY SERVER and DESCRIPTION:

"The script below uses CGI to grab input from a fill-in form; connect to a MySQL Database; and write the fill-in form input to an existing MySQL table. The values that must be changed to reflect your database are marked in red."

#!/usr/bin/perl

use DBI;

use CGI ':standard';

## grab input from fill-in form:

my ($id,$username,$email,$address);

## store the input from fill-in form into varibles:

$id = param('id');

$username = param('username');

$email = param('email');

$address = param('address');

## connect to mySQL database:

$DSN = "DBI:mysql:database_name:localhost";

my $dbh = DBI->connect($DSN, "database_name", "password") || die "Can't Connect";

## insert fill-in form input into database:

my $sel = $dbh->prepare("INSERT INTO table_name VALUES(NULL,?,?,?)");

$sel->bind_param(1, $username);

$sel->bind_param(2, $email);

$sel->bind_param(3, $address);

$sel->execute() && $sel->finish();

$dbh->disconnect;

opifex
09-29-2009, 12:24 AM
OK.First, Perl and your database have absolutely nothing to do with Dreamweaver. If Perl is your language of choice, then there are a ton of tutorials available and a section in this forum.
But to get ou started quickly, there is a decent free program called Form A Table (http://face2interface.com/Products/FormATable.shtml) that might help you out. I personally have never used it, but I have seen it used and it seems to work quite well.
PHP would be another solution. As you are just starting out, it would be best to decide on ONE serverside language to learn to start with and master it before learning another. Us "old guys" mostly started with Perl and/or Python and learned PHP when it was released. PHP has some advantages in ease of scripting over Perl, but both are excellent and useful languages.
As for Dreamweaver.... it's a nice WYSIWYG program, but you still need to learn how to code in a text editor.