天天看點

php之reg,學生資訊管理系統 網站之reg.php

顧名思義,reg.php當然是用來注冊使用者名的,其中的php代碼也不是很難..

$connect=mysql_connect("localhost","root","") or die("連接配接失敗".mysql_error());

mysql_select_db("register_db",$connect) or die("選擇失敗".mysql_error());

$isrepeatcheck = "SELECT * FROM idinfomation WHERE user="."'".$_POST['user']."'";

$isrepeatquery = mysql_query($isrepeatcheck, $connect);

$isrepeat = mysql_fetch_array($isrepeatquery);

if($_POST['user'] != $isrepeat['user'])

{

$sqlinsert = "INSERT INTO idinfomation (id, user, password1,username, cellphone, dorm, qq)

VALUES

('','$_POST[user]','$_POST[password1]','$_POST[username]','$_POST[cellphone]','$_POST[dorm]','$_POST[qq]')";

$doinsert = mysql_query($sqlinsert, $connect) or die("插入失敗".mysql_error());

mysql_close($connect);

這裡是主要的功能,作用也隻是在表中插入值而已,沒什麼技術難度.

我覺得需要注意的是,在每個資料庫函數後都加入

or die(mysql_error())這應該算一個很好的習慣,可以及時的知道你對資料庫操作的錯誤原因.~