我有注册表,它将用户信息保存在'tblusers‘-> 'Username’中,但它不检查用户是否已经存在,所以目前用户可以使用相同的用户名注册,这是一个巨大的混乱。
因此,我需要在注册时检查MySQL数据库中现有的‘用户名’。你知道如何使用PHP - MySQL,甚至是javascript来做到这一点吗?
这是我在表单提交上执行的代码:
check_token ();
$_SESSION['currency'] = $currency;
$clientid = addclient ($firstname, $lastname, $companyname, $email, $address1, $address2, $city, $state,
$postcode, $country, $phonenumber, $password, $securityqid, $securityqans, $sendemail);
//print "New clientid=" . $clientid . "<br>";
update_query ('tblclients', array ('notes' => $notes, 'status' => $status, 'credit' => $credit, 'salesOperatorId' => $salesOperatorId,
'taxexempt' => $taxexempt, 'latefeeoveride' => $latefeeoveride, 'overideduenotices' => $overideduenotices, 'country' => 'US',
'language' => $language, 'billingcid' => $billingcid, 'lastlogin' => '00000000000000'), array ('id' => $clientid));
//print "New clientid now=" . $clientid . "<br>";
savecustomfields ($clientid, $customfield);
$result = select_query ('tblusers', 'ID', array ('ClientID' => $clientid));
// adding user to the DB at same time as client is being added ...
$datenowtimestamp = date("Y-m-d H:i:s");
$table91 = 'tblusers';
$array91 = array ('ClientID' => $clientid, 'firstname' => $userfirstname, 'lastname' => $userlastname, 'email' => $useremail,
'username' => $username, 'password' => $password, 'searchdelivery' => 'Criminal', 'reporttiming' => 'Instant',
'deliverymethod' => 'email', 'Created' => $datenowtimestamp,
'phonenumber' => $phonenumber, 'orderreports' => 1, 'viewallreports' => 1, 'viewpricing' => 1,
'restrictreportview' => 0, 'gatewayaccess' => 0);
insert_query ($table91, $array91);
if($data = mysql_fetch_array ($result))
$userid = $data['ID'];
$header = 'Location: clientsusers.php?clientid=' . $clientid;
//print $header . "<br>";
header ($header);
exit ();发布于 2012-02-01 02:05:17
当用户在注册时输入用户名时,执行ajax检查以查看用户名是否已经存在,并通知用户选择其他内容
https://stackoverflow.com/questions/9084591
复制相似问题