-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax.php
45 lines (40 loc) · 1.12 KB
/
ajax.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
<?php
echo "<pre>";
print_r($_REQUEST);die; //TEST AJAX GETING ALL FEILD DATA
print_r($_FILES);die; //TESTING THE PLAYERS IMAGE FILE GET CURRECTLY OR NOT?
$action = $_REQUEST['action'];
if (!empty($action)) {
require_once 'include/Player.php';
$obj = new Player();
}
if ($action == 'adduser' && !empty($_POST)) {
$pname = $_POST['username'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$photo = $_FILES['photo'];
$pid = (!empty($_POST['userid'])) ? $_POST['userid'] : '';
//validations
//file(photo) upload
$imagename = '';
if (!empty($photo['name'])) {
$imagename = $obj->uploadPhoto($photo);
$playerData = [
'pname' => $pname,
'email' => $email,
'phone' => $phone,
'photo' => $imagename,
];
}else{
$playerData = [
'pname' => $pname,
'email' => $email,
'phone' => $phone,
];
}
$playerId = $obj->add($playerData);
if(!empty($playerId)){
$player = $obj->getRow('id', $playerId);
echo json_encode($player);
exit();
}
}