Skip to content

Commit

Permalink
fix profile-image update bug
Browse files Browse the repository at this point in the history
  • Loading branch information
msaad1999 committed Jan 13, 2020
1 parent ba7d66e commit 7704956
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 17 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
/assets/uploads/users
2 changes: 1 addition & 1 deletion assets/setup/env.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php

if (!defined('APP_NAME')) define('APP_NAME' ,'Login System');
if (!defined('APP_ORGANIZATION')) define('APP_ORGANIZATION' ,'KLiK');
Expand Down
18 changes: 18 additions & 0 deletions assets/setup/env.php.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

if (!defined('APP_NAME')) define('APP_NAME' ,'Login System');
if (!defined('APP_ORGANIZATION')) define('APP_ORGANIZATION' ,'KLiK');


if (!defined('DB_DATABASE')) define('DB_DATABASE', 'klik_loginsystem');
if (!defined('DB_HOST')) define('DB_HOST','127.0.0.1');
if (!defined('DB_USERNAME')) define('DB_USERNAME','root');
if (!defined('DB_PASSWORD')) define('DB_PASSWORD' ,'');
if (!defined('DB_PORT')) define('DB_PORT' ,'');


if (!defined('MAIL_HOST')) define('MAIL_HOST', 'smtp.gmail.com');
if (!defined('MAIL_USERNAME')) define('MAIL_USERNAME', '[email protected]');
if (!defined('MAIL_PASSWORD')) define('MAIL_PASSWORD', 'example-password');
if (!defined('MAIL_ENCRYPTION')) define('MAIL_ENCRYPTION', 'ssl');
if (!defined('MAIL_PORT')) define('MAIL_PORT', 465);
Binary file added assets/uploads/users/_defaultBanner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/uploads/users/_defaultUser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 12 additions & 15 deletions profile-edit/includes/profile-edit.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

$username = $_POST['username'];
$email = $_POST['email'];
$first_name = $_POST['firstl_name'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$gender = $_POST['gender'];
$headline = $_POST['headline'];
Expand Down Expand Up @@ -70,6 +70,17 @@
$fileDestination = '../../assets/uploads/users/' . $FileNameNew;
move_uploaded_file($fileTmpName, $fileDestination);

/*
* -------------------------------------------------------------------------------
* Deleting old profile photo
* -------------------------------------------------------------------------------
*/
if (!unlink('../../assets/uploads/users/' . $_SESSION['profile_image'])) {

$_SESSION['ERRORS']['imageerror'] = 'old image could not be deleted';
header("Location: ../");
exit();
}
}
else
{
Expand All @@ -94,20 +105,6 @@
}


/*
* -------------------------------------------------------------------------------
* Deleting old profile photo
* -------------------------------------------------------------------------------
*/

if (!unlink('../../assets/uploads/users/' . $_SESSION['profile_image'])) {

$_SESSION['ERRORS']['imageerror'] = 'old image could not be deleted';
header("Location: ../");
exit();
}


/*
* -------------------------------------------------------------------------------
* Password Updation
Expand Down

0 comments on commit 7704956

Please sign in to comment.