Skip to content

Commit

Permalink
fetch image
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa Pinto authored and Vanessa Pinto committed Apr 23, 2019
1 parent 0838276 commit 6275729
Show file tree
Hide file tree
Showing 12 changed files with 373 additions and 45 deletions.
19 changes: 19 additions & 0 deletions backend/lookup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
require('connect.php');

$data = $_GET['searchbox'];

$query="SELECT * FROM imagestore WHERE (photographer_id like '%".$data."%') or (category like '%".$data."%') or (tags like '%".$data."%')";
$result = pg_query($connection, $query) or die('Query failed: ' . pg_last_error());

if($result){
echo "success";
}

else {
echo "error";
}

pg_close($connection);

?>
41 changes: 41 additions & 0 deletions backend/save_profile_photo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
require("connect.php");

if(isset($_POST['but_upload']) and isset($_POST['username'])){

$photographer = $_POST['username'];
// $category = $_POST['category'];
// $tags = $_POST['tags'];
$name = $_FILES['file']['name'];
$target_dir = "../profile/";
$target_file = $target_dir . basename($_FILES["file"]["name"]);

// Select file type
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));

// Valid file extensions
$extensions_arr = array("jpg","jpeg","png","gif");

// Check extension
if(in_array($imageFileType,$extensions_arr) ){

// Upload file
move_uploaded_file($_FILES['file']['tmp_name'],$target_dir.$name);
chmod($target_dir.$name, 0755);
// Insert record
$query = "UPDATE public.users_info SET profilepic='$name' WHERE email = '$photographer'";
$result = pg_query($connection, $query) or die('Query failed: ' . pg_last_error());
// if($result){
// echo 'success';
// }
// else {
// echo 'error';
// }

header('Location:../profile-photo.php');

}

}
pg_close($connection);
?>
1 change: 1 addition & 0 deletions dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<li> <a class="waves-effect waves-dark" href="pages-profile.php" aria-expanded="false"><i class="mdi mdi-account-check"></i><span class="hide-menu">Profile</span></a></li>
<li> <a class="waves-effect waves-dark" href="dashboard.php" aria-expanded="false"><i class="mdi mdi-gauge"></i><span class="hide-menu">Dashboard</span></a></li>
<li> <a class="waves-effect waves-dark" href="photos.php" aria-expanded="false"><i class="mdi mdi-image"></i><span class="hide-menu">Photos</span></a></li>
<li> <a class="waves-effect waves-dark" href="profile-photo.php" aria-expanded="false"><i class="mdi mdi-face"></i><span class="hide-menu">Profile Photo</span></a></li>
</ul>
</nav>
<!-- End Sidebar navigation -->
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
</ul>
<!-- Search Form -->
<div class="header-search-form ml-auto">
<form action="search.html">
<form action="search.php">
<input type="search" class="form-control" placeholder="Input your keyword then press enter..." id="search" name="search">
<input class="d-none" type="submit" value="submit">
</form>
Expand Down
2 changes: 1 addition & 1 deletion login.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</ul>
<!-- Search Form -->
<div class="header-search-form ml-auto">
<form action="search.html">
<form action="backend/lookup.php">
<input type="search" class="form-control" placeholder="Input your keyword then press enter..." id="search" name="search">
<input class="d-none" type="submit" value="submit">
</form>
Expand Down
1 change: 1 addition & 0 deletions pages-profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<li> <a class="waves-effect waves-dark" href="pages-profile.php" aria-expanded="false"><i class="mdi mdi-account-check"></i><span class="hide-menu">Profile</span></a></li>
<li> <a class="waves-effect waves-dark" href="dashboard.php" aria-expanded="false"><i class="mdi mdi-gauge"></i><span class="hide-menu">Dashboard</span></a></li>
<li> <a class="waves-effect waves-dark" href="photos.php" aria-expanded="false"><i class="mdi mdi-image"></i><span class="hide-menu">Photos</span></a></li>
<li> <a class="waves-effect waves-dark" href="profile-photo.php" aria-expanded="false"><i class="mdi mdi-face"></i><span class="hide-menu">Profile Photo</span></a></li>
</ul>
</nav>
<!-- End Sidebar navigation -->
Expand Down
2 changes: 1 addition & 1 deletion photographers.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</ul>
<!-- Search Form -->
<div class="header-search-form ml-auto">
<form action="search.html">
<form action="backend/lookup.php">
<input type="search" class="form-control" placeholder="Input your keyword then press enter..." id="search" name="search">
<input class="d-none" type="submit" value="submit">
</form>
Expand Down
1 change: 1 addition & 0 deletions photos.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<li> <a class="waves-effect waves-dark" href="pages-profile.php" aria-expanded="false"><i class="mdi mdi-account-check"></i><span class="hide-menu">Profile</span></a></li>
<li> <a class="waves-effect waves-dark" href="dashboard.php" aria-expanded="false"><i class="mdi mdi-gauge"></i><span class="hide-menu">Dashboard</span></a></li>
<li> <a class="waves-effect waves-dark" href="photos.php" aria-expanded="false"><i class="mdi mdi-image"></i><span class="hide-menu">Photos</span></a></li>
<li> <a class="waves-effect waves-dark" href="profile-photo.php" aria-expanded="false"><i class="mdi mdi-face"></i><span class="hide-menu">Profile Photo</span></a></li>
</ul>
</nav>
<!-- End Sidebar navigation -->
Expand Down
35 changes: 26 additions & 9 deletions portfolio.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,37 @@
session_start();
if (isset($_GET['id'])){
$id = $_GET['id'];
$_SESSION['username'] = $id;
$_SESSION['username'] = $id;
require('backend/connect.php');

$query="SELECT fname,lname,about, designation, profilepic FROM public.users_info WHERE email='$id'";
$result = pg_query($connection, $query) or die('Query failed: ' . pg_last_error());
if(pg_num_rows($result) > 0){
$arr=pg_fetch_all($result);
$fname = $arr[0]['fname'];
$lname = $arr[0]['lname'];
$about = $arr[0]['about'];
$designation = $arr[0]['designation'];
$profilepic = 'profile/'.$arr[0]['profilepic'];
}
else {
echo '<script language="javascript">';
echo "alert('User doesn't exist!')";
echo '</script>';
}
}
pg_close($connection);
?>
<!-- Sidebar with image -->
<div class="imgnav" >
<img src="./img/core-img/side.jpg" class="portfolioimg" height="-webkit-fill-available" />
</div>
<div class="sidenav" >
<?php
echo '<a id="active" href="portfolio.php?id=' .$id. '">About</a>' ;
echo '<a id="side" href="gallery.php?id=' .$id. '">Gallery</a>' ;
echo '<a id="side" href="skills.php?id=' .$id . '">Skills</a>' ;
echo '<a id="active" href="portfolio.php?id=' .$id. '">About</a>' ;
echo '<a id="side" href="gallery.php?id=' .$id. '">Gallery</a>' ;
echo '<a id="side" href="skills.php?id=' .$id . '">Skills</a>' ;
echo '<a id="side" href="portfoliocontact.php?id=' .$id . '">Contact Me</a>';

?>
</div>
<div class="main">
Expand All @@ -62,15 +79,15 @@
<div class="col-10">
<div class="single-blog-area text-center mb-100 wow fadeInUpBig" data-wow-delay="100ms" data-wow-duration="1s">
<div class="blog-thumbnail mb-60">
<img src='./W3.CSS Template_files/profile_girl.jpg' alt="" width="250px" height="320px" width="50%">
<img src=<?php echo htmlspecialchars($profilepic);?> alt="" width="250px" height="320px" width="50%">
</div>
<div class="blog-content">
<br/>
<span></span>
<h2>Jane Doe</h2>
<h2><?php echo htmlspecialchars($fname." ".$lname);?></h2>
<!-- <a href="#" class="post-date">Dec 01, 2017</a> -->
<a href="#" class="post-author">Photographer and Web Designer</a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vel lectus eu felis semper finibus ac eget ipsum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vulputate id justo quis facilisis. Vestibulum id orci ligula. Sed tempor, nunc ut sodales pulvinar, mauris ante euismod magna, at elementum lectus leo sed enim. Praesent dictum suscipit tincidunt. Nulla facilisi. Aenean in mollis orci. Ut interdum vulputate ante a egestas. Pellentesque varius purus malesuada arcu semper vehicula. </p>
<a href="#" class="post-author"><?php echo htmlspecialchars($designation);?></a>
<p><?php echo htmlspecialchars($about);?> </p>
</div>
</div>
</div><br/>
Expand Down
Loading

0 comments on commit 6275729

Please sign in to comment.