forked from gregth/mylib
/
edit_profile.php
38 lines (37 loc) · 1.22 KB
/
edit_profile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require 'models/connect.php';
require 'models/validation_functions.php';
require 'models/user_functions.php';
if ( isset( $_SESSION ) ) {
$emailError = '';
$imageError = '';
if ( !empty( $_POST['newemail'] ) ) {
$valid = validateEmail( $_POST[ 'newemail' ] );
if ( $valid ) {
$success = updateEmail( $_POST[ 'newemail' ], $_SESSION[ 'userid' ] );
if( !$success ) {
$emailError = 'το E-mail';
}
}
else {
$emailError = 'το E-mail';
}
}
if ( !empty( $_FILES[ 'newimg' ] ) ) {
$path = imageUpload ( 'data/profile_imgs/', 'newimg' );
$success = false;
if ( $path ) {
$success = imageUpdate ($path, $_SESSION[ 'userid' ] );
}
if ( !$success ) {
$imageError = 'την Εικόνα';
}
}
if ( $emailError||$imageError ) {
echo "Προσπαθήστε ξάνα υπήρξε πρόβλημα με : $emailError $imageError ";
}
else {
echo 'Ολοκληρώθηκε.';
}
}
?>