forked from nandishkotadia/JP-code-for-good-hackathon
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdummyenter.php
More file actions
70 lines (60 loc) · 1.65 KB
/
dummyenter.php
File metadata and controls
70 lines (60 loc) · 1.65 KB
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
<?php
if(
isset($_POST['username']) &&
isset($_POST['email']) &&
isset($_POST['phno']) &&
isset($_POST['distance']) &&
isset($_POST['speed']) &&
isset($_POST['duration']) &&
isset($_POST['eid']))
$username = $_POST['username'];
$email = $_POST['email'];
$phno = $_POST['phno'];
$distance = $_POST['distance'];
$speed = $_POST['speed'];
$duration = $_POST['duration'];
$earn=$distance*$speed;
$eid= $_POST['eid'];
$con = mysql_connect("localhost","root","");
if(!$con) {
die('Could not connect:'.mysql_error());
}
$amt=0;
$id=0;
mysql_select_db("jpcode",$con);
$query = "INSERT INTO user_details values('','".$username."','".$phno."','".$email."','".$distance."','".$speed."','".$duration."','".$earn."','".$eid."')";
if(mysql_query($query,$con)) {echo "done";}
$queryy="SELECT * from corp_details WHERE id='".$eid."'";
if($result=mysql_query($queryy,$con))
{
//echo 'a';
while($row=mysql_fetch_array($result))
{
$amt=$row['Amount'];
$id=$row['id'];
}
}
$final_amt=$amt-$earn;
$queryyy="UPDATE corp_details SET `Amount`='".$final_amt."' WHERE `id`='".$id."'";
if(mysql_query($queryyy,$con))
{}
$queryyyy="SELECT * FROM leaderboard WHERE `username`='".$username."'";
$result=mysql_query($queryyyy,$con);
if(mysql_num_rows($result)==0)
{
$qin="INSERT into leaderboard values('".$username."','".$earn."')";
$result=mysql_query($qin,$con);
}
else
{
if(mysql_num_rows($result)==1)
{
$qup="UPDATE leaderboard SET earn=earn+'".$earn."' WHERE `username`='".$username."'";
$result=mysql_query($qup,$con);
}
}
?>
<script type="text/javascript" >alert("Data inserted successfully.");</script>
<?php
echo("<script>location.href ='index.php'</script>");
?>