-
-
diff --git a/website/public/settings.php b/website/public/settings.php index 43b1497..b018569 100644 --- a/website/public/settings.php +++ b/website/public/settings.php @@ -1,7 +1,12 @@
- + @@ -12,13 +17,20 @@ * This view adds the main layout over the screen. * Header and menu. */ + include("../views/main.php"); +if ($_SERVER["REQUEST_METHOD"] == "POST") { + updateSettings(); +}?> + + diff --git a/website/public/styles/settings.css b/website/public/styles/settings.css index da55ec4..f1648c8 100644 --- a/website/public/styles/settings.css +++ b/website/public/styles/settings.css @@ -21,6 +21,10 @@ text-align: right; } +.settings-password label, .settings-email label { + text-align: left; +} + /* All the fields for typing things. */ .settings input[type="password"], .settings input[type="text"], diff --git a/website/queries/connect.php b/website/queries/connect.php index 36d1001..ef3e1ba 100644 --- a/website/queries/connect.php +++ b/website/queries/connect.php @@ -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'); } diff --git a/website/queries/settings.php b/website/queries/settings.php new file mode 100644 index 0000000..66ddda8 --- /dev/null +++ b/website/queries/settings.php @@ -0,0 +1,46 @@ +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(); +} \ No newline at end of file diff --git a/website/views/head.php b/website/views/head.php index fc28320..9306edf 100644 --- a/website/views/head.php +++ b/website/views/head.php @@ -15,6 +15,6 @@ \ No newline at end of file diff --git a/website/views/settings-view.php b/website/views/settings-view.php index 15ee39c..49ad1f9 100644 --- a/website/views/settings-view.php +++ b/website/views/settings-view.php @@ -1,39 +1,29 @@ + +