if (isset($_POST["Submit"])) { if ($_POST['password'] !== $_POST['vpassword']) { echo "<script> alert('Whoops! Seems like your passwords do not match.'); </script>"; $name = $_POST['name']; $email = $_POST['email']; } else { $host = "localhost"; $dbuser = "******"; $dbpassword = "******"; $database = "calendapp"; $table = "users"; $connector = new SQLConnector(new Credentials($host, $dbuser, $dbpassword, $database)); $connector->connect(); $w = new ImageWorker(null); //no sql here $id = $w->uploadToDir("/profilepics", "photo"); //Upload profile picture $username = trim($_POST["name"]); $email = trim($_POST['email']); $cryptpw = password_hash($_POST['password'], PASSWORD_DEFAULT); $date = date(DATE_ISO8601); $sqlQuery = "insert into users values('{$username}', '{$cryptpw}', '{$id}', '{$date}', '{$email}')"; if ($connector->insert($sqlQuery)) { $_SESSION['loggedIn'] = true; //Stay logged in $_SESSION['username'] = $username; $_SESSION['email'] = $email; } header('Location: signUpComplete.php'); } } else {
<?php require_once "uploadimage.php"; require_once "dbLogin.php"; require_once "sqlconnector.php"; session_start(); if (isset($_SESSION['username'])) { $CurrentUserName = $_SESSION['username']; } else { $CurrentUserName = "******"; } $host = "localhost"; $dbuser = "******"; $dbpassword = "******"; $database = "calendapp"; $table = "users"; $connector = new SQLConnector(new Credentials($host, $dbuser, $dbpassword, $database)); $connector->connect(); $CurrentEmail = ""; $DateJoined = $connector->retrieve("select joined from users where name='{$_SESSION['username']}'")['joined']; if (isset($_POST['submit'])) { $w = new ImageWorker(null); //no sql here $id = $w->uploadToDir("/profilepics", "filename"); $connector->insert("update users set profilepic='{$id}' where name='{$_SESSION['username']}'"); } $ProPic = "profilepics/" . $connector->retrieve("select profilepic from users where email='{$_SESSION['email']}'")['profilepic']; echo "\n <html>\n <head>\n <title>Profile</title>\n <link rel='stylesheet' href='profile.css' type='text/css' />\n </head>\n <body>\n <a href='main.php'> <img src='img/CalendAppLogo.png' width='256' height='73' alt='CalendApp' id='logo'> </a>\n <div id='subtitle'>\n <img src='img/Pro.png' alt='Profile' id='subtitle'>\n </div>\n \n <form action='profile.php' enctype='multipart/form-data' method='post' id='form'>\n\t\t\t <h1>{$CurrentUserName}</h1>\n <img src='{$ProPic}' alt = 'Profile Picture' id='propic'/>\n\t\t\t <p>\n Date Joined: {$DateJoined}\n </p>\n <p id='upload'>\n Upload New Profile Picture\n <input type='file' name='filename'/><br /><input type='submit' name='submit' value='Upload'>\n </p>\n \n \n </form> \n </body>\n </html>";