# Is this correct?

**URL:** <https://forum.kirupa.com/t/is-this-correct/218465>\
**Category:** Uncategorized\
**Created:** [March 8, 2007, 12:09am UTC](https://forum.kirupa.com/t/is-this-correct/218465 "2007-03-08T00:09:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flash\_Man1](https://avatars.discourse-cdn.com/v4/letter/f/8797f3/32.png) [@Flash\_Man1](https://forum.kirupa.com/u/Flash_Man1)\
**Post date:** [March 8, 2007, 12:09am UTC](https://forum.kirupa.com/t/is-this-correct/218465/1 "2007-03-08T00:09:16Z")

</div>

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 😃  
Here is my code:

```php
<?

$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!
