檢查用戶名是否已在mysql中存在的php寫法
更新時間:2014年01月20日 15:57:53 作者:
檢查用戶名是否已在mysql中存在的方法有很多,下面為大家介紹下使用php是如何做到的
在寫注冊系統(tǒng)時,如果要檢查用戶名是否存在,php可以這樣寫:
$username=$_REQUEST['username'];
$password=$_REQUEST['password'];
echo "<br/>excute the insertUserInfo";
$con=mysqli_connect("localhost","root","","my_db");
$sql="SELECT * FROM user WHERE username='$username'";
ho "<br/>this username aready exists"; } else { $sql="INSERT INTO user (username,password) VALUES ('$username','$password')"; if(!mysqli_query($con,$sql)) { echo "<br/>Error".mysqli_error($con); } else { echo "<br/>one record added"; } }
建議不要用:
mysql_num_rows($result)</pre>
lt;pre name="code" class="html"></pre>
復(fù)制代碼 代碼如下:
$username=$_REQUEST['username'];
$password=$_REQUEST['password'];
echo "<br/>excute the insertUserInfo";
$con=mysqli_connect("localhost","root","","my_db");
$sql="SELECT * FROM user WHERE username='$username'";
ho "<br/>this username aready exists"; } else { $sql="INSERT INTO user (username,password) VALUES ('$username','$password')"; if(!mysqli_query($con,$sql)) { echo "<br/>Error".mysqli_error($con); } else { echo "<br/>one record added"; } }
建議不要用:
復(fù)制代碼 代碼如下:
mysql_num_rows($result)</pre>
lt;pre name="code" class="html"></pre>
您可能感興趣的文章:
- php+mysql大量用戶登錄解決方案分析
- 使用phpMyAdmin修改MySQL數(shù)據(jù)庫root用戶密碼的方法
- PureFTPd+Mysql+PHP_Manager實(shí)現(xiàn)虛擬用戶磁盤限額的配置方法
- php中存儲用戶ID和密碼到mysql數(shù)據(jù)庫的方法
- android+json+php+mysql實(shí)現(xiàn)用戶反饋功能方法解析
- 如何用phpmyadmin設(shè)置mysql數(shù)據(jù)庫用戶的權(quán)限
- 使用PHPMYADMIN操作mysql數(shù)據(jù)庫添加新用戶和數(shù)據(jù)庫的方法
- php為什么選mysql作為數(shù)據(jù)庫? Mysql 創(chuàng)建用戶方法
- 用PHP寫的MySQL數(shù)據(jù)庫用戶認(rèn)證系統(tǒng)代碼
- php+mysql實(shí)現(xiàn)用戶注冊登陸的方法
相關(guān)文章
PHP簡單讀取PDF頁數(shù)的實(shí)現(xiàn)方法
這篇文章主要介紹了PHP簡單讀取PDF頁數(shù)的實(shí)現(xiàn)方法,涉及php針對文件的讀取及正則運(yùn)算等相關(guān)操作技巧,需要的朋友可以參考下2016-07-07
解析在PHP中使用mysqli擴(kuò)展庫對mysql的操作
本篇文章是對在PHP中使用mysqli擴(kuò)展庫對mysql的操作進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-07-07
詳解WordPress中調(diào)用評論模板和循環(huán)輸出評論的PHP函數(shù)
這篇文章主要介紹了WordPress中調(diào)用評論模板和循環(huán)輸出評論的PHP函數(shù),分別是comments_template函數(shù)與wp_list_comments函數(shù)的使用,需要的朋友可以參考下2016-01-01
PHP 刪除文件與文件夾操作 unlink()與rmdir()這兩個函數(shù)的使用
有時候我們需要用PHP來刪除文件和文件夾,PHP本來也都有函數(shù)可以實(shí)現(xiàn),下面簡單記錄一下代碼,方便以后信守拈來。2011-07-07
PHP CURL模擬登錄新浪微博抓取頁面內(nèi)容 基于EaglePHP框架開發(fā)
PHP CURL模擬登錄新浪微博抓取頁面內(nèi)容 基于EaglePHP框架開發(fā),需要的朋友可以參考下。2012-01-01
PHP實(shí)現(xiàn)自動登入google play下載app report的方法
這篇文章主要介紹了PHP實(shí)現(xiàn)自動登入google play下載app report的方法,較為詳細(xì)的講述了登陸下載APP及對應(yīng)的實(shí)現(xiàn)代碼,具有不錯的實(shí)用價值,需要的朋友可以參考下2014-09-09
PHP簡單實(shí)現(xiàn)二維數(shù)組賦值與遍歷功能示例
這篇文章主要介紹了PHP簡單實(shí)現(xiàn)二維數(shù)組賦值與遍歷功能,涉及php數(shù)組的簡單賦值、遍歷、運(yùn)算、讀取等操作使用技巧,需要的朋友可以參考下2017-10-10

