$NgaySinh = $_POST["dtpNgaySinh"]; } else { $NgaySinh = '1/1/1900'; } $nguoi_dung->NgaySinh = date("Y-m-d", strtotime($NgaySinh)); $nguoi_dung->AnhDaiDien = ''; // chuyển về định dạng YYYY-mm-dd để insert vào mysql // giới tính if (isset($_POST["cboGioiTinh"])) { $nguoi_dung->GioiTinh = $_POST["cboGioiTinh"]; } else { $nguoi_dung->GioiTinh = 1; } // 1: nam; 2: nữ // tìm xem tên user có trong csdl hay chưa? $check_user_name = NguoiDungDAO::LayThongTinNguoiDungTheoTenTaiKhoan($nguoi_dung->UserName); if (!is_null($check_user_name)) { $mess .= "Tên tài khoản đã tồn tại, <a href='dang_ky.php'>click vào đây </a> để thử lại."; echo $frmThongBao_BD . $mess . $frmThongBao_KT; return; } // tìm xem email có trong csdl hay chưa? $check_email = NguoiDungDAO::LayThongTinNguoiDungTheoEmail($nguoi_dung->Email); if (!is_null($check_email)) { $mess .= "Email đã tồn tại, <a href='dang_ky.php'>click vào đây </a> để thử lại."; echo $frmThongBao_BD . $mess . $frmThongBao_KT; return; } // xử lý ảnh đại diện $types = array('image/jpeg', 'image/gif', 'image/pjpeg'); $fileName = "";
require_once 'class/NguoiDungDAO.php'; $username = $_POST["txtUserName"]; $password = $_POST["txtPassword"]; if (isset($_POST["btnLogin"])) { mysql_connect("localhost", "root", "") or die("Not connect host"); mysql_select_db("shopping_here") or die("Not connect database"); // mã hóa password = md5 $password = md5($password); $check_user_name = NguoiDungDAO::LayThongTinNguoiDungTheoTenTaiKhoan($username); if (is_null($check_user_name)) { echo "<script>alert('Tên đăng nhập này chưa tồn tại!');</script>"; echo "<meta http-equiv='refresh' content='1;url=index.php'/>"; } else { $result = NguoiDungDAO::KiemTraDangNhap($username, $password); if ($result) { $nguoiDungDto = NguoiDungDAO::LayThongTinNguoiDungTheoTenTaiKhoan($username); // set session: $_SESSION['IsLogin'] = true; $_SESSION['IdUser'] = $nguoiDungDto->MaNguoiDung; $_SESSION['UserName'] = $nguoiDungDto->UserName; $_SESSION['Authentication'] = $nguoiDungDto->MaLoaiND; $response = "\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t<div class='standard_error'>\r\n\t\t\t\t\t\t<form class='block vbform' method='post' action='#' name='postvarform'>\r\n\t\t\t\t\t\t\t<h2 class='blockhead'>Ðang chuyển tới ...</h2>\r\n\t\t\t\t\t\t\t<div class='blockbody formcontrols'>\r\n\t\t\t\t\t\t\t\t<p class='blockrow restore'>Cảm ơn, <strong>{$username}</strong> đã đăng nhập thành công<br><br> </p>\r\n\t\t\t\t\t\t\t\t<center>Shopping-Here website mua bán hàng đầu Việt Nam</center>\r\n\t\t\t\t\t\t\t\t<p></p>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t<div class='blockfoot actionbuttons redirect_button'>\r\n\t\t\t\t\t\t\t\t<div class='group' id='redirect_button'>\r\n\t\t\t\t\t\t\t\t\t<a href='index.php' class='textcontrol'>[ Click vào đây nếu trình duyệt không tự chuyển ]</a>\r\n\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t</form>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t"; //echo "<p align='center' style='font:arial; color:#000; font-size:14px;'>Đăng nhập thành công! Đang chuyển hướng về trang chủ</p>"; if ($nguoiDungDto->MaLoaiND == 3) { echo $response; echo "<meta http-equiv='refresh' content='3;url=admin.php'/>"; } else { echo $response; echo "<meta http-equiv='refresh' content='3;url=index.php'/>"; } } else {