Logging Form Data to Access Database Using PHP

Hello Everyone,
I'm trying to finish up the development on my first website.  I've been working on this for a few weeks now (when I have time) and I have received very valuable help from Ray and Marco.  Here are some of the previous threads if you're interested.  

Here, Here, and Here

Initially I wanted the "contact me" form to send me an email on Submit.  Ray recommended I change my approach and log the data into a database instead.  That way I don't have to worry about ISP's catching my emails in their spam filters.  So that's what I did.  Here is my problem.

Everything was working fine on my localhost but when I uploaded my site to the GoDaddy server it doesn't work anymore.

When I initially uploaded the new site to the GoDaddy server I received an error saying some driver was not installed.  I googled for a while and found the Select PHP Version manager in the cPanel.
Select PHP VersionThis link takes you to another screen where you can select whatever options (or drivers?) you want to install (I think).  Honestly, I don't really know what it does when you check one of the boxes.
Select PHP Version Options
I checked the "pdo_odbc" box.  I did this b/c I needed to uncomment the "extension=php_pdo_odbc.dll" line in my php.ini file in order to get it work work on my local host.  

So, now when I click the submit button I don't get the error about the missing driver anymore.  Now the submit button does nothing.   I called GoDaddy tech support and they couldn't help me but they did tell me a few things that might be the problem.

1.  They said I may need to add a User.ini file to my root directory in order to make the necessary settings for the PHP to work correctly.  No idea what this means.
2.  They said Access databases are not supported on the type of server I have.  They said I have to use a mySQL database.  Can that be true!  Why is it working on my local machine?

Here is a snippet from my JS file where I make the $_Post call.
if(hasError == false) {
	$.post("PHP/log_contact.php", {frmName: nameVal, frmEmail: emailVal, frmMessage: messageVal}, 
		function(data) {
			document.getElementById("msgSuccess").style.display = "block";

Open in new window

Here is my entire PHP file

$dbName = $_SERVER["DOCUMENT_ROOT"] . "/GerberEngineering/dbFolder/ContactLog.accdb";	//For local testing
//$dbName = $_SERVER["DOCUMENT_ROOT"] . "/dbFolder/ContactLog.accdb";					//For use on GoDaddy server
$connStr = "odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=" . $dbName . ";";

echo $dbName;

if (!file_exists($dbName)) {
    die("Could not find database file.");

$db = new PDO($connStr);

$strName = $_POST['frmName'];
$strEmail = $_POST['frmEmail'];
$strMessage = $_POST['frmMessage'];
$Date = date('Y-m-d H:i:s');

$sql  = "INSERT INTO ContactLog";
$sql .= " (ContactName, Email, Message, ContactDate)";
$sql .= " VALUES ('" . $strName . "', '" . $strEmail . "', '" . $strMessage . "', '" . $Date . "')";



Open in new window

I know this is a difficult problem since it is dealing with a specific web host but I would appreciate any help I could get.  If you need me to upload any other files I can definitely do that.

LVL 12
kgerbChief EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>> They said Access databases are not supported on the type of server I have.  They said I have to use a mySQL database.  Can that be true!
Absolutely! Before you can even connect to a database, you need a driver for the database in question.  If they are telling you that Access is not supported on that server, that means there is no driver for it on that server.

>> Why is it working on my local machine?
Because you have the necessary MS Access driver installed. If they are not willing to install the drivers for you, start focusing on migrating your db to MySQL.  If you are on a shared hosting account, most web hosting companies typically will not install custom drivers for a client, since doing so will impact every hosting client on the machine.

If I were you, I would try to replicate their environment on my local machine as much as possible.  Find out the php version & mysql version they have.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
Godaddy?  Really?
I called GoDaddy tech support and they couldn't help me...
Welcome to the real world.

@hielo writes:
...start focusing on migrating your db to MySQL.
Good advice, and still I have a slightly different viewpoint.  Why in the world would you choose GoDaddy, when we all know that it's among the cheapest hosting companies (and in this case, price and value correlate)?  

Why not choose one of the PHP-friendly web hosts listed in the PHP "Thanks" web page?

Another idea: Make a Google search for "professional web hosting companies" and see what the community has to suggest.

Web site hosting is a commodity.  It has one and only one differentiating characteristic: Good technical support.  Consider ChiHost, LiquidWeb, DreamHost and others that are recognized and recommended in online forums that are frequented by experienced developers.

Dave BaldwinFixer of ProblemsCommented:
Ray is mostly right but there are cheaper and worse web hosting companies.  Support is the primary difference.  I only know of two web hosts that support Access databases.  One is Godaddy but Only on older Windows accounts.  Their current offerings do not support Microsoft Access.  The other one is not accepting new web customers.

Even with the 'new' versions, Microsoft Access is a desktop Office application.  It is Not a database server like MySQL and SQL Server which were designed from the start for server and multi-user access.
kgerbChief EngineerAuthor Commented:
Thanks everyone for your answers.  I'm in the process of converting the database to mySQL.  Really there's no conversion.  There's only one table.  But, I've never used mySQL before so I'm sure I'll be posting again when I get stuck.  

Oh, and Ray, next time don't hold back.  Tell me how you really feel! :-)

Thanks again,
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.