-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.php
60 lines (47 loc) · 1.36 KB
/
check.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
session_start();
require_once "DB.php";
function checkForm($formData)
{
$db=new MysqlAdapter();
if (sizeof($formData)>2){
$Email=$formData['Email'];
$query= 'Email='."'$Email'";
$db->select('users',$query);
if($user=$db->fetch()){
$errArray['Email'] = "*Was used";
}
}
foreach ($formData as $key=>$value){
if (isset($formData[$key]) && empty($formData[$key])) {
$errArray[$key] = "*error";
}
}
return $errArray;
}
function checkLogin($Email , $Password){
$errArray=[];
$db=new MysqlAdapter();
// $db->select('users','Name='.$Name. 'and Email='.$Email);
$query= 'Email='."'$Email'". ' and Password='. "'$Password'";
$db->select('users',$query);
if($user=$db->fetch()){
print_r ($user);
$_SESSION['ID']=$user['ID'];
$_SESSION['Name']=$user['Name'];
$_SESSION['Email']=$user['Email'];
$_SESSION['Role']=$user['Role'];
$_SESSION['Image']=$user['Image'];
return $errArray;
}
$errArray['Email'] = "*error";
$errArray['Password'] = "*error";
return $errArray;
}
function addPhoto($file){
$target_dir = "uploads/";
$photoName=time().$file['Image']['name'];
$uploadfile = $target_dir .$photoName ;
move_uploaded_file($file['Image']['tmp_name'], $uploadfile);
return $photoName;
}