php+Mysql頁面註冊代碼

來源:互聯網
上載者:User

標籤:register   頁面   輸入   submit   lang   var_dump   pass   sel   type   

版面設定代碼:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="register_post.php" method="post">
<table>
<tr>
<td>使用者名稱:</td>
<td><input type="text" name="uname" placeholder="請輸入帳號"></td>
</tr>
<tr>
<td>密碼:</td>
<td><input type="password" name="pwod" placeholder="請輸入密碼"></td>
</tr>
</table>
<input type="submit" value="註冊">
</form>
</body>
</html>

註冊處理頁面代碼:
<?php
/**
* Created by xx.
* User: msi
* Date: 2017/10/24
* Time: 11:00
*/

header("content-type:text/html; charset=utf-8");

//引入前面的DBDA方法集檔案
require_once "../DBDA.class.php";
$db = new DBDA();
var_dump($_POST);
if(!empty($_POST)) {
$uname = $_POST["uname"];
//查詢使用者註冊的使用者名稱是否和資料庫已有的使用者名稱重複,並返回查詢結果;
$sql = "select * from t_user WHERE uname = ‘{$uname}‘";
// echo $sql;
$result = $db->strQuery($sql);

//}
if ($result != "0") {
exit("使用者名稱字被佔用");
} else {
$sql_insert = "insert into t_user(uname,pwod) VALUES (‘{$_POST["uname"]}‘,‘{$_POST["pwod"]}‘)";
echo $sql_insert;
$result2 = $db->Query($sql_insert, 0);
var_dump($result2);
}
}
//echo "張三";
//echo $_POST[‘uname‘];
//echo $_POST[‘pwod‘];
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>

</body>
</html>
這樣就完成啦!

php+Mysql頁面註冊代碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.