-
Notifications
You must be signed in to change notification settings - Fork 0
/
submithandler.php
executable file
·89 lines (74 loc) · 2.06 KB
/
submithandler.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* Created: Nov 9,2017
* Author: Muhammad Ayaz
* Email: mailtomayaz@gmail.com
*/
include 'includes/functions.php';
//$add = $_POST['add'];
//
//echo $str = "insert into user_info (name,email,phone,location) values('$username','$useremail',$userphone,'$userlocation')";
//add user information into database
if (isset($_POST['add'])){
// save file attachment if exist
$add = '';
$ifFile='';
if(isset($_FILES)){
$ifFile = getFileUpload($con,$_FILES);
}
$add = addUser($con,$_POST,$ifFile);
if($add){
echo "Recored added";
echo "<a href='/crud'> Go back </\a>";
}else {
echo "There is problem saving Record";
echo "<a href='/crud'> Go back </\a>";
}
}
//update record
if (isset($_POST['update'])){
//echo "update user_info set name='$username',email='$useremail',phone='$userphone',location='$userlocation' where id=$id ";
//print_r($_FILES);
// die('stop');
if($_FILES['userFileUpload']['size']!= 0 ){
$ifFile = getFileUpload($con,$_FILES);
if($ifFile){
//echo "add file name";
$update = getUpdateUser($con,$_POST,$ifFile);
}
}else{
$update = getUpdateUser($con,$_POST);
}
//$update = getUpdateUser($con,$_POST);
if($update){
echo "Record Updated";
echo "<a href='/crud'> Go back </\a>";
}
}
//view records
if(isset($_GET['view'])){
// show record with ID
$id= $_GET['view'];
$userData = getUserById($con,$id);
include 'view.php';
}
//edit records
if(isset($_GET['edit'])){
// edit record with ID
$id= $_GET['edit'];
$userData = getUserById($con,$id);
include 'edit.php';
}
//delete records
if(isset($_GET['delete'])){
// delete record with ID
$id= $_GET['delete'];
$deleted = getUserDelete($con,$id);
if($deleted){
echo "Record Deleted";
echo "<a href='/crud'> Go back </\a>";
}
}