-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.php
217 lines (190 loc) · 6.16 KB
/
index.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<?php
include("functions.php");
$wrongpass = '';
$wronginfo = '<div class="alert alert-danger" role="alert"> <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Wrong login detail</div>';
if(isloggedin()==FALSE)
{
}
else
{
header("location:home.php");
}
if(isset($_POST['email']) && ($_POST['pass']))
{
$pass= mysqli_real_escape_string($conn, $_POST['pass']);
$email= mysqli_real_escape_string($conn, $_POST['email']);
$query="SELECT * from users where uemail='$email'";
$result = $conn->query($query);
if ($result->num_rows < 1)
{
$wrongpass = $wronginfo;
}
while($row = $result->fetch_assoc())
{
if(md5($pass)==$row['upass'])
{
$_SESSION['logged_in']=TRUE;
$_SESSION['id']=$row['uid'];
$_SESSION['unaam']=$row['uname'];
session_start();
header("location:home.php");
}
else
{
$wrongpass = $wronginfo;
}
}
}
?>
<head>
<title>Daily Expenses Manager</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
<link rel="icon" type="image/png" href="images/favicon.png" />
<meta name=viewport content="width=device-width, initial-scale=1">
<script type="text/javascript">
$(document).ready(function(){
$("#name").keyup(function() {
var name = $('#name').val();
if(name=="")
{
$("#disp").html("");
}
else
{
$.ajax({
type: "POST",
url: "check.php",
data: "name="+ name ,
success: function(html){
$("#disp").html(html);
}
});
return false;
}
});
});
</script>
</head>
<body>
<div style="padding:10px; margin:10px;">
<div class="panel panel-primary">
<div class="panel-heading"><b>Daily Expense Manager</b></div>
<div class="panel-body">
<div class="row">
<div class="col-md-3">
<div class="panel panel-success">
<div class="panel-heading"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> Signin with your existing Account</div>
<div class="panel-body">
<form class="form-horizontal" name="login" action="index.php" method="post">
<div class="form-group">
<label for="Email" class="col-sm-3 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="Email" placeholder="Email" name="email" required>
</div>
</div>
<div class="form-group">
<label for="Password" class="col-sm-3 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="Password" placeholder="Password" name="pass" required>
</div>
</div>
<?php
echo $wrongpass;
?>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">Sign in</button>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="col-md-3">
<img src="images/demo.jpg" alt="..." class="img-thumbnail img-responsive">
</div>
<div class="col-md-6">
<div class="panel panel-primary">
<div class="panel-heading"><span class="glyphicon glyphicon-hand-right" aria-hidden="true"></span> New user? Create your free Account</div>
<div class="panel-body">
<form class="form-horizontal" action="index.php" method="post">
<div class="form-group">
<label for="fname" class="col-sm-2 control-label" >Full Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="fname" name="fname" autocomplete="off" required placeholder="Write your full name here">
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" id="name" name="name" class="form-control" autocomplete="off" required placeholder="Email">
<div id="disp"></div>
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" name="password" class="form-control" id="inputPassword3" required placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label>
<input type="checkbox" required> Agreed terms and conditions
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-success">Create My Account</button>
</div>
</div>
</form>
<?php
if(isset($_POST['name']) && trim($_POST['password']) != "")
{
$name= mysqli_real_escape_string($conn, $_POST['name']);
$query="SELECT * from users where uemail='$name'";
$result = $conn->query($query);
if ($result->num_rows < 1)
{
$uname = mysqli_real_escape_string($conn, $_POST['fname']);
$uname = strip_tags($uname);
$uemail = mysqli_real_escape_string($conn, $_POST['name']);
$uemail = strip_tags($uemail);
$upass = mysqli_real_escape_string($conn, $_POST['password']);
$upass = md5($upass);
$sql = "INSERT INTO users (uname, uemail, upass)
VALUES ('$uname','$uemail','$upass')";
if ($conn->query($sql) === TRUE)
{
echo '<div class="alert alert-success" role="alert">
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span> Your account has been created successfully!
</div>';
} else
{
echo "Error: " . $sql . "<br>" . $conn->error;
}
} else
{
echo '<div class="alert alert-danger" role="alert">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> You already have an account and can access from login form
</div>';
}
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="alert alert-info" role="alert">
<p><strong>Daily Expense Manager</strong> is a simple PHP script to manage your expenses with multi-user level.It designed to help individual or business budget, track and possibly control your expenses. It supports tracking of both your expenses and income. This expense management system provides an integrated set of features to help you to manage your expenses and cash flow. It provides the ability to group your income/expenses into categories and lets you set a budget and track expenses in the category.</p>
<a href=" https://youtu.be/-lsoxJi7Xs4" class="alert-link">Dont Know how to use!, click here.</a>
</div>
</div>
</body>