Login
require_once('facebook.php'); $config = array( 'appId' => 'YOUR_APP_ID',//809203845855838 'secret' => 'YOUR_APP_SECRET',//564f7c4320c406561d0367d029440248 ); $facebook = new Facebook($config); $user_id = $facebook->getUser(); if($user_id) { try { $ret_obj = $facebook->api('/me/feed', 'POST', array( 'link' => 'www.toiyeu5ptamn.blogspot.com', 'message' => 'Posting with the PHP SDK! on http://toiyeu5ptamn.blogspot.com' )); echo '
Post ID: ' . $ret_obj['id'] . '
'; } catch(FacebookApiException $e) { $login_url = $facebook->getLoginUrl( array( 'scope' => 'publish_stream' )); echo 'Please login.'; error_log($e->getType()); error_log($e->getMessage()); } echo '
logout'; } else { $login_url = $facebook->getLoginUrl( array( 'scope' => 'publish_stream' ) ); echo 'Please login.'; }

Thứ Sáu, 14 tháng 8, 2015

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 ''; } } }

Không có nhận xét nào:

Đăng nhận xét

version="1.0" encoding="UTF-8"?> Viettel *99# 0 e-connect 1 1 IP PAP 0 0