This is just killing me!
I am getting an error message 'Duplicate entry 'Chuck's Termite' for key 2'.
Here is my table.
CREATE TABLE i6users (
id int(11) NOT NULL auto_increment,
isgod enum('Y','N') DEFAULT 'N' NOT NULL,
canadd enum('1','0') DEFAULT '0' NOT NULL,
login varchar(12) NOT NULL,
password varchar(12) NOT NULL,
handle varchar(20) NOT NULL,
realname varchar(50),
email varchar(50) NOT NULL,
address varchar(150) NOT NULL,
description tinytext NOT NULL,
type tinyint(4) DEFAULT '0' NOT NULL,
phone varchar(15) NOT NULL,
fax varchar(15) NOT NULL,
state varchar(10) NOT NULL,
zip varchar(10) NOT NULL,
city varchar(20) NOT NULL,
PRIMARY KEY (id),
UNIQUE handle (handle),
UNIQUE login (login)
);
Now, when I take out the unique attribute of handle, which is creating this error, I get duplicate entries into the database. Here is my php code. What is interesting is that I am getting duplicate header and footer in the browser as well.
HELP Please!
-Tim
<?
/
confirm.php - confirm user signup
/
require('../config.inc.php');
require('../functions.inc.php');
$i6link = db_connect();
if ($i6global[signup] && isset($ikea)) {
if ( good_confirmation($ikea) ) {
$q = "UPDATE i6signups SET confirmed='1' WHERE ikea='$ikea'";
@mysql_query($q,$i6link) or die (mysql_error());
$q = "SELECT * FROM i6signups WHERE ikea='$ikea'";
$result = mysql_query($q,$i6link) or die (mysql_error());
$u = mysql_fetch_object($result);
/* leftover from failure to addslashes when taken from signup..
$u->realname = addslashes($u->realname);
$u->email = addslashes($u->email);
$u->url = addslashes($u->url);
$u->description = addslashes($u->description);
*/
$q = "INSERT INTO i6users (login,password,handle,realname,email,
description,type,address,city,state,zip,phone,fax)
VALUES ('$u->login','$u->password','$u->handle','$u->realname','$u->email',
'$u->description','$u->type','$u->address','$u->city','$u->state','$u->zip','$u->phone','$u->fax')
";
@mysql_query($q,$i6link) or die (mysql_error());
if ($u->type == 0)
$q = "UPDATE i6users SET canadd=1 where email='$u->email'";
@mysql_query($q,$i6link) or die (mysql_error());
db_close($i6link);
$pageid="signup";
include($i6templates[header]);
wr_box_top("Confirmed","75%");
echo "
Thank you for confirming your account.<p>
<a href=\"$i6global[httproot]\">Click here</a> to login!
";
wr_box_bottom();
include($i6templates[footer]);
} else {
$pageid="signup";
include($i6templates[header]);
wr_error_top("Error","75%");
echo "
I'm sorry, but that is a bad confirmation number,
or the account has already been confirmed.
";
wr_error_bottom();
include($i6templates[footer]);
}
} else {
db_close($i6link);
header("Location: $i6global[httproot]");
}
?>