I'm trying to create a registration/login script using Access 2003. I'm using ADOdb to connect through ODBC.
[CODE=php]<?php
// Connects to your Database
include('adodb/adodb.inc.php') ; # load code common to ADOdb
$db = &ADONewConnecti on('access'); # create a connection
$db->PConnect('evdb '); # connect to MS-Access, evdb DSN
$db->debug = true;
//This code runs if the form has been submitted
if (isset($_POST['submit'])) {
//This makes sure they did not leave any fields blank
if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {
die('You did not complete all of the required fields, <a href="reg.php"> Return</a>');
}
// checks if the username is in use
if (!get_magic_quo tes_gpc()) {
$_POST['username'] = addslashes($_PO ST['username']);
}
$usercheck = $_POST['username'];
$check = $db->GetRow("SELE CT user.username FROM [user] WHERE username = '$usercheck'")
or die('<b>Could Not Connect to Server</b>');
$check2 = count($check);
//if the name exists it gives an error
if ($check2 != 0) {
die('Sorry, the username '.$_POST['username'].' is already in use.');
}
// this makes sure both passwords entered match
if ($_POST['pass'] != $_POST['pass2']) {
die('Your passwords did not match.');
}
// here we encrypt the password and add slashes if needed
$_POST['pass'] = md5($_POST['pass']);
if (!get_magic_quo tes_gpc()) {
$_POST['pass'] = addslashes($_PO ST['pass']);
$_POST['username'] = addslashes($_PO ST['username']);
}
// now we insert it into the database
$insert = "INSERT INTO user ( username, password )
VALUES ('".$_POST['username']."','".$_POS T['pass']."')";
//echo $insert;
$add_member = $db->Execute($inser t);
?>
[/CODE]
The problem is that I get the little custom error Could Not Connect to Server when I try to insert a record, yet when I use the form with a username I inserted through Access it reads it just fine and returns if the username has been used. Also if I removed line line 23 (the one with the error) and it'll complete the script, but it won't insert the record.
[CODE=php]<?php
// Connects to your Database
include('adodb/adodb.inc.php') ; # load code common to ADOdb
$db = &ADONewConnecti on('access'); # create a connection
$db->PConnect('evdb '); # connect to MS-Access, evdb DSN
$db->debug = true;
//This code runs if the form has been submitted
if (isset($_POST['submit'])) {
//This makes sure they did not leave any fields blank
if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {
die('You did not complete all of the required fields, <a href="reg.php"> Return</a>');
}
// checks if the username is in use
if (!get_magic_quo tes_gpc()) {
$_POST['username'] = addslashes($_PO ST['username']);
}
$usercheck = $_POST['username'];
$check = $db->GetRow("SELE CT user.username FROM [user] WHERE username = '$usercheck'")
or die('<b>Could Not Connect to Server</b>');
$check2 = count($check);
//if the name exists it gives an error
if ($check2 != 0) {
die('Sorry, the username '.$_POST['username'].' is already in use.');
}
// this makes sure both passwords entered match
if ($_POST['pass'] != $_POST['pass2']) {
die('Your passwords did not match.');
}
// here we encrypt the password and add slashes if needed
$_POST['pass'] = md5($_POST['pass']);
if (!get_magic_quo tes_gpc()) {
$_POST['pass'] = addslashes($_PO ST['pass']);
$_POST['username'] = addslashes($_PO ST['username']);
}
// now we insert it into the database
$insert = "INSERT INTO user ( username, password )
VALUES ('".$_POST['username']."','".$_POS T['pass']."')";
//echo $insert;
$add_member = $db->Execute($inser t);
?>
[/CODE]
The problem is that I get the little custom error Could Not Connect to Server when I try to insert a record, yet when I use the form with a username I inserted through Access it reads it just fine and returns if the username has been used. Also if I removed line line 23 (the one with the error) and it'll complete the script, but it won't insert the record.
Comment