Is this correct?

Hey all,

what i’m trying to do is insert a record in a MS Access database through php.

  • I will be entering records in flash and passing the variables one which will be the URL to php and if the URL isn’t matching in my database then i want it to insert the name and email else don’t insert record.

  • I think i hope my code is correct please check if this is correct and suggest any easier or better ways to do this or correct way.

Cheers Everyone :smiley:
Here is my code:

<?

$name = $_GET['name'];
$email = $_GET['email'];
$id = $_GET['ADOR'];

//http://www.php.net/manual/en/class.com.php
function db($sql, $db) {
$c = new COM("ADODB.Connection");
$c->open("Provider=Microsoft.Jet.OLEDB.4.0; DBQ=$db");
$r = $c->execute($sql);
$i = 0;
$num_fields = $r->fields->count();
while (!$r->EOF)
{
for($j = 0;$j<$num_fields;$j++) {
$key = $r->Fields($j);
$r_items[$i][$key->name] = $key->value;
}
$i++;
$r->MoveNext();
}
$r->close();
$c->close();
$r = null;
$c = null;
return $r_items;
}

$db = getcwd() . "D:\something.mdb";
$results = db("SELECT * FROM `sheet1` WHERE `URL` = "$id"",$db);
foreach($result as $i => $item) {
echo $item[0];
echo $item[1];

if ($item ! $id) {
$results = db("INSERT INTO `Email`, `Fullname` VALUES ("$name", "$email"",$db)
$createID = db("INSERT INTO `recipientID` VALUES (`$id`) SET recipientID=recipientID+1",$db);
}


?>

p.s. the top part of the code is a code snippet i found to connect to a MS Access Database.

not sure if it’s correct though…Thanks Again!