Example #1
0
<?php

require_once '../bootstrap.php';
if (!Auth::check()) {
    header("Location: login.php");
    exit;
}
$user = Auth::user();
$user_id = User::loggedInUserID($user);
$listings = Ad::allUsersListings($user_id);
// var_dump($listings);
?>

<html>
<head>
    <title>Instrument Exchange</title>
    <!-- Bootstrap styling -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <!-- Custom styling for site -->
    <link rel="stylesheet" type="text/css" href="../css/main.css">
</head>
<body>
    <? include "../views/partials/navbar.php"; ?>


    <div class="container">

        <div class="row listing-wrapper">

            <h1><?php 
echo $userInfo[0]['name'];
Example #2
0
            if (move_uploaded_file($_FILES['somefile']['tmp_name'], $filename)) {
                $image_status = '<p>The file ' . basename($_FILES['somefile']['name']) . ' has been uploaded.</p>';
            } else {
                $image_status = "Sorry, there was an error uploading your file.";
            }
        }
    }
    try {
        $ad->image_url = $filename;
    } catch (Exception $e) {
        $errors['image_url'] = "An error occurred: " . $e->getMessage();
    }
    $ad->date_posted = date('Y-m-d');
    $userEmail = Auth::user();
    var_dump($userEmail);
    $userID = User::loggedInUserID($userEmail);
    var_dump($userID);
    $ad->user_id = $userID;
    if (empty($errors)) {
        var_dump($ad);
        $ad->save();
        header("Location: success.php");
        exit;
    }
}
// ONLY AFTER auth check, can a user create a
// listing - only registered users can
// create/edit/update/delete their own listings.
// Non-registered users must create an account
// first before they can create a new listing to sell.
?>