triggermorf
New member
I am trying to insert data from a form into an access database but it is just refusing to work. I am getting no errors. Some help would be great as I am very new to PHP. My code is below:
<?php
$db = realpath("db\testdatabase.mdb");
$conn = new COM('ADODB.Connection') or exit('Cannot start ADO.');
$connStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=$db";
$conn->Open($connStr);
$test_lastname = $_GET['test_lastname'];
$test_firstname = $_GET['test_firstname'];
$test_password = $_GET['test_password'];
$sql = "INSERT INTO testtable (test_lastname, test_firstname, test_password) VALUES('$test_lastname', '$test_firstname', '$test_password')";
$rs = @odbc_exec($conn,$sql);
?>
<html>
<head>
</head>
<body>
<?php
echo $sql . "<br />";
if (!$rs)
{
echo "error";
}
else
{
echo "success";
}
$conn->close;
?>
</body>
</html>
<?php
$db = realpath("db\testdatabase.mdb");
$conn = new COM('ADODB.Connection') or exit('Cannot start ADO.');
$connStr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=$db";
$conn->Open($connStr);
$test_lastname = $_GET['test_lastname'];
$test_firstname = $_GET['test_firstname'];
$test_password = $_GET['test_password'];
$sql = "INSERT INTO testtable (test_lastname, test_firstname, test_password) VALUES('$test_lastname', '$test_firstname', '$test_password')";
$rs = @odbc_exec($conn,$sql);
?>
<html>
<head>
</head>
<body>
<?php
echo $sql . "<br />";
if (!$rs)
{
echo "error";
}
else
{
echo "success";
}
$conn->close;
?>
</body>
</html>