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;
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;