Thứ Sáu, 14 tháng 8, 2015
g
@charset "utf-8";
/* CSS Document */
a{text-decoration:none; color:#006699}
a:hover{color:#00FF00; text-decoration:none}
#thongtinphanhoi{background:#F0FFFF;; width:710px; height:1500px; line-height:30px}
#noidungconthongtinphanhoi{background:#F0FFFF; width:600px; height:400px; margin:50px; line-height:30px}
#tieuchuannguoidung{background:#000000; width:600px; height:32px; line-height:30px; color:#FFFFFF; border-top-left-radius:8px;border-top-right-radius:8px;}
#caucotendangnhap{background:#F0FFFF; width:600px; height:80px; line-height:30px; color:#333333 }
#caucotendangnhap1{background:#F0FFFF; width:600px; height:30px; line-height:30px; }
#caucotendangnhap21{background:#F0FFFF; width:600px; height:24px; line-height:23px; }
#cuasodangnhap{background:#F0FFFF; width:600px; height:38px; line-height:23px; }
#cuasodangnhap1{background:#F0FFFF; width:170px; height:28px; line-height:23px; margin:5px; float:left}
#cuasodangnhap2{background:#F0FFFF; width:380px; height:28px; line-height:23px; margin:5px; float: left}
#1{width:350px; height:25px; border-radius:20px}
f
// Thiết lập charset utf8
header('Content-Type: text/html; charset=utf-8');
// Vì tên button submit là do-register nên ta sẽ kiểm tra nếu
// tồn tại key này trong biến toàn cục $_POST thì nghĩa là người
// dùng đã click register(submit)
if (isset($_POST['do-register']))
{
// Lấy thông tin
// Để an toàn thì ta dùng hàm mssql_escape_string để
// chống hack sql injection
$username = isset($_POST['username']) ? mysql_escape_string($_POST['username']) : '';
$password = isset($_POST['password']) ? md5($_POST['password']) : '';
$email = isset($_POST['email']) ? mysql_escape_string($_POST['email']) : '';
$phone = isset($_POST['phone']) ? mysql_escape_string($_POST['phone']) : '';
$level = isset($_POST['level']) ? (int)$_POST['level'] : '';
// Validate Thông Tin Username và Email có bị trùng hay không
// Kết nối CSDL
$conn = mysqli_connect('localhost', 'root', 'vertrigo', 'demo') or die ('Lỗi kết nối');
mysqli_set_charset($conn, "utf8");
// Kiểm tra username hoặc email có bị trùng hay không
$sql = "SELECT * FROM member WHERE username = '$username' OR email = '$email'";
// Thực thi câu truy vấn
$result = mysqli_query($conn, $sql);
// Nếu kết quả trả về lớn hơn 1 thì nghĩa là username hoặc email đã tồn tại trong CSDL
if (mysqli_num_rows($result) > 0)
{
// Sử dụng javascript để thông báo
echo '';
// Dừng chương trình
die ();
}
else {
// Ngược lại thì thêm bình thường
$sql = "INSERT INTO member (username, password, email, phone, level) VALUES ('$username','$password','$email','$phone', '$level')";
if (mysqli_query($conn, $sql)){
echo '';
}
else {
echo '';
}
}
}
c
"; else print "Table \"members\" chưa được tạo do lỗi truy vấn SQL.
"; if ($add_admin) print "TK Admin:
User: admin
Pass:admin
"; else print "Ko thể tạo tài khoản admin vì lỗi SQL.
"; echo 'Click vào đầy để xem Demo'; ?>
Đăng Ký
Chào mừng các bạn đến với diễn đàn cocolee.info
//Kiem tra button Register if(isset($_POST["btnRegister"])) { mysql_connect("localhost","root","")or die("Not connect host"); mysql_select_db("login")or die("Not select database"); if(!$_POST["txtFullName"] || !$_POST["txtUserName"] || !$_POST["txtPassword"]) { echo "Nhập đầy đủ thông tin
"; exit(); } //mã hóa password $_POST["txtPassword"]=md5($_POST["txtPassword"]); $check=mysql_query("select UserName from users where UserName = '$_POST[txtUserName]'"); if(mysql_num_rows($check)==0) { $result=mysql_query("insert into users (FullName, UserName, Password) value('$_POST[txtFullName]','$_POST[txtUserName]','$_POST[txtPassword]')"); if($result) { echo "Đăng ký thành công Quay về Trang chủ
"; } else echo "Lỗi đăng ký
"; } else { echo "Tên đăng nhập đã có người sử dụng
"; } } ?>
Đăng ký:
Bài đăng (Atom)