Facebook login implemented

This commit is contained in:
Joey Lai
2017-01-31 16:12:22 +01:00
parent 08f668859c
commit 8e98001217
82 changed files with 11126 additions and 133 deletions

View File

@@ -16,6 +16,22 @@ function getExistingUsername() {
}
function getExistingFBUsername() {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`username`
FROM
`user`
WHERE
`username` LIKE :username
");
$stmt->bindValue(":username", test_input($_POST["fbUsername"]));
$stmt->execute();
return $stmt->rowCount();
}
function getExistingEmail() {
$stmt = $GLOBALS["db"]->prepare("
SELECT
@@ -32,6 +48,23 @@ function getExistingEmail() {
}
function getExistingFBEmail() {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`email`,
`userID`
FROM
`user`
WHERE
`email` LIKE :email
");
$stmt->bindValue(":email", test_input($_POST["fbEmail"]));
$stmt->execute();
return $stmt->rowCount();
}
function getResetEmail() {
$stmt = $GLOBALS["db"]->prepare("
SELECT
@@ -67,12 +100,16 @@ function registerAccount() {
:location,
:email
)");
$day_date = test_input(($_POST["day_date"]));
$month_date = test_input(($_POST["month_date"]));
$year_date = test_input(($_POST["year_date"]));
$bday = $year_date . "-" . $month_date . "-" . $day_date;
$hash=password_hash($_POST["password"], PASSWORD_DEFAULT);
$stmt->bindValue(":fname", test_input($_POST["name"]));
$stmt->bindValue(":lname", test_input($_POST["surname"]));
$stmt->bindValue(":bday", test_input($_POST["bday"]));
$stmt->bindValue(":bday", test_input($bday));
$stmt->bindValue(":username", test_input($_POST["username"]));
$stmt->bindValue(":password", test_input($hash));
$stmt->bindValue(":location", test_input($_POST["location"]));
@@ -82,6 +119,42 @@ function registerAccount() {
$stmt->rowCount();
}
function fbRegisterAccount() {
$stmt = $GLOBALS["db"]->prepare("
INSERT INTO
`user`(fname,
lname,
birthdate,
username,
password,
email,
role)
VALUES(
:fname,
:lname,
:bday,
:username,
:password,
:email,
'user'
)");
$fbDay_date = test_input(($_POST["fbDay_date"]));
$fbMonth_date = test_input(($_POST["fbMonth_date"]));
$fbYear_date = test_input(($_POST["fbYear_date"]));
$fbBday = $fbYear_date . "-" . $fbMonth_date . "-" . $fbDay_date;
$hash=password_hash($_POST["fbPassword"], PASSWORD_DEFAULT);
$stmt->bindValue(":fname", test_input($_POST["fbName"]));
$stmt->bindValue(":lname", test_input($_POST["fbSurname"]));
$stmt->bindValue(":bday", test_input($fbBday));
$stmt->bindValue(":username", test_input($_POST["fbUsername"]));
$stmt->bindValue(":password", test_input($hash));
$stmt->bindValue(":email", test_input(strtolower($_POST["fbEmail"])));
return $stmt->execute();
}
function submitselect($date, $value){
if ($date == $value){
echo "selected";