Setting loadin, settings update, db is now global
This commit is contained in:
@@ -5,7 +5,7 @@ if ($dbconf === FALSE) {
|
||||
die("Error parsing XML file");
|
||||
}
|
||||
else {
|
||||
$db = new PDO("mysql:host=$dbconf->mysql_host;dbname=$dbconf->mysql_database;charset=utf8",
|
||||
$GLOBALS["db"] = new PDO("mysql:host=$dbconf->mysql_host;dbname=$dbconf->mysql_database;charset=utf8",
|
||||
"$dbconf->mysql_username", "$dbconf->mysql_password")
|
||||
or die('Error connecting to mysql server');
|
||||
}
|
||||
|
||||
46
website/queries/settings.php
Normal file
46
website/queries/settings.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
function getSettings() {
|
||||
$stmt = $GLOBALS["db"]->prepare("
|
||||
SELECT
|
||||
`fname`,
|
||||
`lname`,
|
||||
`email`,
|
||||
`location`,
|
||||
`birthdate`,
|
||||
`bio`,
|
||||
`profilepicture`
|
||||
FROM
|
||||
`user`
|
||||
WHERE
|
||||
`userID` = :userID
|
||||
");
|
||||
|
||||
$stmt->bindParam(":userID", $_SESSION["userID"]);
|
||||
$stmt->execute();
|
||||
return $stmt->fetch();
|
||||
}
|
||||
|
||||
function updateSettings() {
|
||||
$stmt = $GLOBALS["db"]->prepare("
|
||||
UPDATE
|
||||
`user`
|
||||
SET
|
||||
`fname` = :fname,
|
||||
`lname` = :lname,
|
||||
`location` = :location,
|
||||
`birthdate` = :bday,
|
||||
`bio` = :bio
|
||||
WHERE
|
||||
`userID` = :userID
|
||||
");
|
||||
|
||||
$stmt->bindParam(":fname", $_POST["fname"]);
|
||||
$stmt->bindParam(":lname", $_POST["lname"]);
|
||||
$stmt->bindParam(":location", $_POST["location"]);
|
||||
$stmt->bindParam(":bday", $_POST["bday"]);
|
||||
$stmt->bindParam(":bio", $_POST["bio"]);
|
||||
$stmt->bindParam(":userID", $_SESSION["userID"]);
|
||||
|
||||
$stmt->execute();
|
||||
}
|
||||
Reference in New Issue
Block a user