$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: contact@email.com';
$to = $email;
$subject = "Confirmation";
$message = "Hi, $username. You're registred in Site. Link for confirmation: http://site.com/confirm/**".mysql_insert_id()."**";
mail($to, $subject, $message, $headers);
$query = mysql_query("insert into usr_users(username, password, email, avator, pin) values('$username', '$password', '$email', '$img', '$pin')");
$query2 = mysql_query("insert into usr_confirm(user_name, user_id, active, data) values('$username', '".mysql_insert_id()."', '$active', '$senha')");
echo"Success!</br>";
第二个mysql_insert_id()(第 9 行)是正确的!但是第一个 mysql_insert_id()(第 6 行)在电子邮件中返回 0。