php 後台資料庫與前台請求結合

來源:互聯網
上載者:User
$_GET擷取 get請求中參數值    $username = $_GET["userName"];    $password = $_GET["password"];    echo("username:".$username."  password:".$password);*/    // POST請求,開啟網頁沒值    // 擷取 body 體中,這兩個變數的值/*    $username = $_POST["username"];    $password = $_POST["password"];    if($username == "houzhichao" && $password == 12345) {        $dic = array("code"=>200,"message"=>"登入成功");        echo(json_encode($dic));    } else {        $dic = array("code"=>404,"message" =>"登入失敗");        echo(json_encode($dic));    }*/// 註冊結合資料庫去使用,將前台寫的東西,寫到伺服器資料庫中// 1.擷取 使用者 GET體中參數的值$username = $_GET[username];$password = $_GET[password];// 2.使用資料庫// (1)串連資料庫 mysql_connect// 參數1:服務// 參數2:登入資料庫的使用者名稱,我們選的是根使用者// 參數3:密碼,當為空白,可以省// ** 有個傳回值 BOOL$islink = mysql_connect("127.0.0.1","root","");if($islink) {    echo("資料庫連接成功
"
); // (2)選擇資料庫 mysql_select_db mysql_select_db("DataBase"); // (3)查詢資料庫中的使用者表,有沒有當前的使用者名稱;傳回值(指令集 or BOOL) mysql_query // results是一個 數組(都是記錄),查詢全部的內容 $results = mysql_query("select username from users"); while($row = mysql_fetch_array($results)) { // 判斷 row 記錄中的使用者名稱是否跟當前註冊的使用者名稱一樣 if($row["username"] == $username) { echo("註冊失敗,使用者名稱已存在
"
); return ; } } // 可以進行註冊操作 // 相當於向 users 的表中,插入資料 $result = mysql_query("insert into users(username,password)values('$username','$password')"); if($result) { echo("註冊成功
"
); } else { echo("註冊失敗
"
); }} else { echo("連結失敗");}?>

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('
  • ').text(i)); }; $numbering.fadeIn(1700); }); });

    以上就介紹了php 後台資料庫與前台請求結合,包括了方面的內容,希望對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.