項目總結——PHP小型網站經驗總結

來源:互聯網
上載者:User

標籤:lin   技術   代碼   charset   reg   echo   mime   smart   member   

                          記於物件導向之前----小型網站開發

這次的項目,開始的時候總覺得不是特別在意,沒有將其當做屬於自己的一份責任,總是覺得自己有時間去完成,而沒有很認真,直到這次的項目即將完成,才知道,追悔莫及。

這次是我們小組項目的一次完成以及代碼的一些執行個體,也算是給自己的一份交代吧

這次項目運用了MySQL+PHP+Apache+Smarty技術綜合體系,沒有對其進行完整的解釋,望見諒。

<?php
header("Content-Type: text/html;charset=utf-8");//非常重要,一定要指定MIME為text/xml
header("Cache-Control:no-cache");//告訴瀏覽器不要快取資料
//接收資料
require "./commDB.php";//包含串連資料庫檔案
$memberName=$_GET[‘username‘];
$info = "";//申明一個Null 字元串用來裝返回的XML資料
if(strlen($memberName)==0)
{
$info .= ‘{"res":""}‘;
}
else{
$sql = "select id from user where username=‘".$memberName."‘;";
$result = mysql_query($sql);
$memberID = array();
while($row = mysql_fetch_assoc($result))
{
$memberID[] = $row;
}
if(empty($memberID))
{
$reg = "/^[a-zA-Z]/";//必須以字母開頭的Regex
if(preg_match($reg,$memberName))
{
if(strlen($memberName)<6)
{
$info.=‘{"res":"*使用者名稱不能小於6位"}‘;//這裡資料是返回給請求的頁面.
}
else{
$info.=‘{"res":"使用者名稱可用√"}‘;//這裡資料是返回給請求的頁面.
}
}
else{
$info.=‘{"res":"*使用者名稱必須字母開頭"}‘;//這裡資料是返回給請求的頁面.
}
}
else{
$info.=‘{"res":"*該使用者名稱已經存在"}‘;//這裡資料是返回給請求的頁面.
}
}
echo $info;

<?php
$link = @mysql_connect("localhost", "root" ,"") or die(‘資料庫選擇失敗!‘);
mysql_select_db("lovoinfo", $link);
mysql_query("set names utf8");

?>

項目總結——PHP小型網站經驗總結

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.