Пример #1
0
session_start();
//error_reporting(0);
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');
Пример #2
0
<?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>";
Пример #3
0
\t\t\t<h3> Select an image that you would lke to upload. Include a caption and at least two tags.</h3>
\t\t\t\t <p>
\t\t\t\t\tEnter image to upload (as user {$user}): &nbsp;
\t\t\t\t\t<input type="file" name="filename" required="required" /><br />
\t\t\t\t\tCaption: &nbsp; <input type="text" required="required" name="caption" /><br />
\t\t\t\t\tTags (comma separated): &nbsp; <input type="text" id='tags' name="tags" required="required" /><br />
\t\t\t\t\t<br>
\t\t\t\t\t<input type="submit" name='submit' value="Post" id='post'/>
\t\t\t\t</p>   
\t\t   </form>
\t   </body>
\t  </html>

BODY;
echo generatePage($body);
$iw = new ImageWorker(new Credentials("localhost", "user", "user", "calendapp"));
if (isset($_POST['submit'])) {
    if (isset($_SESSION['username'])) {
        $username = $_SESSION['username'];
    } else {
        $username = "******";
    }
    $tags = $_POST['tags'];
    $caption = $_POST['caption'];
    if ($id = $iw->uploadImage($username, $tags, $caption)) {
        //echo "Successful upload with id $id"; //Placeholder
        echo "<script> alert('Successfully uploaded image!')</script>";
        header("Location: main.php");
    } else {
        echo "<script> alert('Upload failed. (" . $iw->getError() . ")')</script>";
    }
Пример #4
0
<?php

require_once "support.php";
require_once "uploadimage.php";
require_once "dbLogin.php";
//$body =<<<BODY
?>
     <form action="uploadtest.php" enctype="multipart/form-data" method="post">
      <p>
   	     <b>Enter image to upload: </b>
   	     <input type="file" name="filename" /><br />
   	     <input type="submit" name='submit' value="uploadImage" />
      </p>
      
      </form>

<?php 
echo generatePage($body);
$iw = new ImageWorker(new Credentials("localhost", "user", "user", "calendapp"));
if (isset($_POST['submit'])) {
    if ($id = $iw->uploadImage("test", "nothing", "hello world")) {
        echo "Successful upload with id {$id}";
    }
}