slimjimscot
Programmer
Hi,
I'm writing a Perl CGI script to send a newsletter to e-mail addresses stored in a MySQL database. I have my script stored in a cgi-bin directory and I have a web form that I write a message into and it POSTs the results to the cgi.
I can access the MySQL database ok using the DBI interface,e.g.
$dbh = DBI ->connect('DBI:mysql:dbasename: 'dbaseuser', 'password', {RaiseError => 1 })
I would rather not have the account name and password visible in this file - as the cgi-bin directory is in the web directory (i.e. open to the web world). I tried storing the account details in another file, opening it, and putting the account details into varables - but the DBI interface doesn't seem to resolve variables (i.e. replacing the account names in the script line above with variables).
Does anyone have any ideas how I use a CGI to access a database via Perl, but without revealing the actual database account details in the script?
Does Perl have some type of 'include' facility like PHP - were you can store the part of the script that opens the database in a file somewhere else, and just include at the appropriate place in the CGI script?
I hope that all makes sense.
I've not done a lot of Perl scripting - so I apologise if this is a stupid question with an obvious answer.
Thanks,
Jim
I'm writing a Perl CGI script to send a newsletter to e-mail addresses stored in a MySQL database. I have my script stored in a cgi-bin directory and I have a web form that I write a message into and it POSTs the results to the cgi.
I can access the MySQL database ok using the DBI interface,e.g.
$dbh = DBI ->connect('DBI:mysql:dbasename: 'dbaseuser', 'password', {RaiseError => 1 })
I would rather not have the account name and password visible in this file - as the cgi-bin directory is in the web directory (i.e. open to the web world). I tried storing the account details in another file, opening it, and putting the account details into varables - but the DBI interface doesn't seem to resolve variables (i.e. replacing the account names in the script line above with variables).
Does anyone have any ideas how I use a CGI to access a database via Perl, but without revealing the actual database account details in the script?
Does Perl have some type of 'include' facility like PHP - were you can store the part of the script that opens the database in a file somewhere else, and just include at the appropriate place in the CGI script?
I hope that all makes sense.
I've not done a lot of Perl scripting - so I apologise if this is a stupid question with an obvious answer.
Thanks,
Jim