-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessor.php
144 lines (124 loc) · 3.82 KB
/
processor.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
include "conn.php";
date_default_timezone_set("Asia/Kolkata");
session_start();
if(isset($_POST['submit_user']))
{
$name=$_POST['name'];
$email=$_POST['email'];
$credit=$_POST['credits'];
$date=date("jS F Y");
$time=date("h:i:s a");
$sql="INSERT INTO users(name,email,credits,`current-date`,`current-time`) VALUES('$name','$email','$credit','$date','$time')";
$query=mysqli_query($conn,$sql);
if($query)
{
$result = '<p class="alert-success">New User Added</p>';
$_SESSION['result']=$result;
header("location:".$_SERVER['HTTP_REFERER']);
exit();
}
else
{
$result = '<p class="alert-danger">User Not Added</p>';
$_SESSION['result']=$result;
header("location:".$_SERVER['HTTP_REFERER']);
exit();
}
}
if(isset($_GET['del']))
{
$id=$_GET['del'];
$sql="DELETE FROM users WHERE id='$id'";
$query=mysqli_query($conn,$sql);
if($query)
{
$result = '<p class="alert-success">User Deleted</p>';
$_SESSION['result']=$result;
header("location:".$_SERVER['HTTP_REFERER']);
exit();
}
else
{
$result = '<p class="alert-danger">Cannot Delete User</p>';
$_SESSION['result']=$result;
header("location:".$_SERVER['HTTP_REFERER']);
exit();
}
}
if(isset($_POST['transfer']))
{
$from=$_POST['transfer_from'];
$to=$_POST['transfer_to'];
$credit=$_POST['credit_transfer'];
$date=date("jS F Y");
$time=date("h:i:s a");
$transfer_data = "INSERT INTO transfer(transfer_from,transfer_to,credits,`transfer-date`,`transfer-time`) VALUES('$from','$to','$credit','$date','$time')";
$query_transfer = mysqli_query($conn,$transfer_data);
$previous="SELECT * FROM users where email='$to'";
$prev_query=mysqli_query($conn,$previous);
while($row=mysqli_fetch_array($prev_query))
{
$new_value = intval($row['credits']) + intval($credit);
// echo $new_value;
$insert_new="UPDATE users SET credits='$new_value' WHERE email='$to'";
$sql_new=mysqli_query($conn,$insert_new);
}
$sub_sender="SELECT * FROM users WHERE email='$from'";
$sub_query=mysqli_query($conn,$sub_sender);
while($row2=mysqli_fetch_array($sub_query))
{
$new_sub_value = intval($row2['credits']) - intval($credit);
// echo $new_sub_value;
$insert_updated="UPDATE users SET credits='$new_sub_value' WHERE email='$from'";
$sql_update=mysqli_query($conn,$insert_updated);
if($sql_update)
{
$result = '<p class="alert-success">Credits Transferred</p>';
$_SESSION['result']=$result;
header("location:".$_SERVER['HTTP_REFERER']);
exit();
}
else
{
$result = '<p class="alert-danger">Cannot Transfer Credits</p>';
$_SESSION['result']=$result;
header("location:".$_SERVER['HTTP_REFERER']);
exit();
}
}
}
if(isset($_POST['submit_feedback']))
{
$name=$_POST['name'];
$email=$_POST['email'];
$rating=$_POST['rating'];
$feedback=$_POST['feedback'];
$sql="INSERT INTO feedback(name,email,rating,message) VALUES('$name','$email','$rating','$feedback')";
$query=mysqli_query($conn,$sql);
$to = "rktech50@gmail.com";
$subject = "Feedback From Credit Management";
$message = "<b>Name : ".$name."</b>";
$message .= "<b>Email : ".$email."</b>";
$message .= "<b>Rating : ".$rating." / 10</b>";
$message .= "<p>Feedback : ".$feedback."</p>";
$header = "From:feedback@credit-management.com \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$retval = mail ($to,$subject,$message,$header);
if($query == true && $retval == true)
{
$result = '<p class="alert-success">Message Sent Successfully...</p>';
$_SESSION['result']=$result;
header("location:".$_SERVER['HTTP_REFERER']);
exit();
}
else
{
$result = '<p class="alert-danger">Cannot Send Message !</p>';
$_SESSION['result']=$result;
header("location:".$_SERVER['HTTP_REFERER']);
exit();
}
}
?>