Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
11 views19 pages

Inventory Management Removed

The document contains PHP code for a login system with functionalities for user registration, password reset, and displaying customer sale reports. It includes session management, form handling, and database interactions to fetch customer details and sales data. The code is structured to handle different actions based on user input through GET parameters.

Uploaded by

titikshasbala1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views19 pages

Inventory Management Removed

The document contains PHP code for a login system with functionalities for user registration, password reset, and displaying customer sale reports. It includes session management, form handling, and database interactions to fetch customer details and sales data. The code is structured to handle different actions based on user input through GET parameters.

Uploaded by

titikshasbala1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

login.

php
<?php

session_start

();

// Check if user is already

logged in

if(isset($_SESSION['logged

In'])){

header('Location:

index.php'); exit();

require_once('inc/config/

constants.php');

require_once('inc/config/d

b.php');

require_once('inc/header.

html');

?>
<body>

<?php
// Variable to store the action (login, register,
passwordReset)
$action = '';
1
if(isset($_GET['action']))

$action =

$_GET['action'];

if($action ==

'register'){
?>
<div class="container">
<div class="row justify-content-center">

2
<div class="col-sm-12 col-md-5 col-lg-5">
<div class="card">
<div class="card-

header">

Register

</div>
<div class="card-body">
<form action="">
<div id="registerMessage"></div>
<div class="form-group">
<label

for="registerFullName">Name<span
class="requiredIcon">*</span></label>
<input type="text" class="form-
control" id="registerFullName"
name="registerFullName">
<!-- <small id="emailHelp"
class="form-text text-
muted"></
small> -->
</div>
<div class="form-group">
<label

for="registerUsername">Username
<span
class="requiredIcon">*</span></label>
<input type="email"
class="form-control"
id="registerUsername" name="registerUsername"
autocomplete="on">

3
</div>
<div class="form-group">
<label

for="registerPassword1">Password<span
class="requiredIcon">*</span></label>
<inputtype="password"
class="form-control"
id="registerPassword1" name="registerPassword1">
</div>
<div class="form-group">
<label

for="registerPassword2">Re-enter password<span
class="requiredIcon">*</span></label>

4
<inputtype="password"
class="form-control"
id="registerPassword2" name="registerPassword2">
</div>
<a href="login.php" class="btn btn-
primary">Login</a>
<button type="button"
id="register" class="btn
btn-
success">Register</button>
<a href="login.php?
action=resetPassword" class="btn
btn-
warning">Reset Password</a>
<button type="reset"
class="btn">Clear</button>
</form>
</div>
</div>
</div>
</div>
</div>

<?
php
require

'inc/footer.php'

; echo

'</body></htm

l>'; exit();
?>
} elseif($action == 'resetPassword'){

5
ify-content-center">
<
d <div class="col-sm-12 col-md-5 col-lg-5">
i <div class="card">
v
<div class="card-
c
l header">
a Reset
s
s Password
=
" </div>
c <div class="card-body">
o
n <form action="">
t
a
i
n
e
r
"
>
<
d
i
v
c
l
a
s
s
=
"
r
o
w

j
u
s
t
6
<div
id="resetPasswordMessage"></div>
<div class="form-group">
<label
for="resetPasswordUsername">Username</label>
<input type="text" class="form-
control" id="resetPasswordUsername"
name="resetPasswordUsername">
</div>
<div class="form-group">
<label

for="resetPasswordPassword1">N
ew
Password</label>
<inputtype="password"
class="form-control"
id="resetPasswordPassword1"
name="resetPasswordPassword1">
</div>
<div class="form-group">
<label

for="resetPasswordPassword2">C
onfirm
New Password</label>
<inputtype="password"
class="form-control"
id="resetPasswordPassword2"
name="resetPasswordPassword2">
</div>
<a href="login.php" class="btn btn-
primary">Login</a>

7
<a href="login.php?action=register"
class="btn btn-
success">Register</a>
<buttontype="button"
id="resetPasswordButton"
class="btn btn-warning">Reset Password</button>
<button type="reset"
class="btn">Clear</button>
</form>
</div>
</div>
</div>
</div>
</div>
<?php

8
require

'inc/footer.php'

; echo

'</body></htm

l>'; exit();

}
}
?>
<!-- Default Page Content (login form) -->
<div class="container">
<div class="row justify-content-center">
<div class="col-sm-12 col-md-5 col-lg-5">
<div class="card">
<div class="card-

header"> Login

</div>
<div class="card-body">
<form action="">
<div id="loginMessage"></div>
<div class="form-group">
<label
for="loginUsername">Username</label>
<input type="text" class="form-
control" id="loginUsername"
name="loginUsername">
</div>
<div class="form-group">

9
<label
for="loginPassword">Password</label>
<input type="password" class="form-
control" id="loginPassword" name="loginPassword">
</div>
<button type="button" id="login"
class="btn btn-
primary">Login</button>
<a href="login.php?action=register"
class="btn btn-
success">Register</a>

10
<ahref="login.php?action=resetPassword"
class="btn btn-
warning">Reset Password</a>
<button type="reset"
class="btn">Clear</button>
</form>
</div>
</div>
</div>
</div>
</div>
<?php
require 'inc/footer.php';
?>
</body>
</html>

customer

populateCustomerDetails.php
<?php

require_once('../../inc/config/con

stants.php');

require_once('../../inc/config/db.

php');

// Execute the script if the POST request is

11
submitted if(isset($_POST['customerID'])){

$customerID = htmlentities($_POST['customerID']);

$customerDetailsSql = 'SELECT * FROM customer


WHERE customerID =
:customerID';
$customerDetailsStatement = $conn-
>prepare($customerDetailsSql);

12
$customerDetailsStatement->execute(['customerID'
=> $customerID]);

// If data is found for the given item number,

return it as a json object

if($customerDetailsStatement->rowCount()

> 0) {

$row = $customerDetailsStatement-

>fetch(PDO::FETCH_ASSOC); echo

json_encode($row);
}
$customerDetailsStatement->closeCursor();
}
?>

populateLastCustomerID.php

<?php

require_once('../../inc/config/con

stants.php');

require_once('../../inc/config/db.

php');

$sql = "SELECT MAX(customerID) FROM customer";


$stmt = $conn->prepare($sql);
$stmt->execute();

13
$row = $stmt->fetch(PDO::FETCH_ASSOC);

echo $row['MAX(customerID)'];
$stmt->closeCursor();
?>

saleReportsSearchTableCreator.php
<?php

require_once('../../inc/config/con

stants.php');

14
require_once('../../inc/config/db.php');

$uPrice = 0;
$qty = 0;
$totalPrice = 0;

$saleDetailsSearchSql = 'SELECT * FROM sale';


$saleDetailsSearchStatement = $conn-
>prepare($saleDetailsSearchSql);
$saleDetailsSearchStatement->execute();

$output = '<table id="saleReportsTable" class="table


table-sm table-striped table- bordered table-hover"
style="width:100%">
<thead>
<tr>
<th>Sale ID</th>
<th>Item Number</th>
<th>Customer ID</th>
<th>Customer Name</th>
<th>Item Name</th>
<th>Sale Date</th>
<th>Discount %</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Total Price</th>
</tr>

15
</thead>
<tbody>';

// Create table rows from the selected data

16
while($row = $saleDetailsSearchStatement-
>fetch(PDO::FETCH_ASSOC)){
$uPrice = $row['unitPrice'];
$qty = $row['quantity'];
$discount = $row['discount'];
$totalPrice = $uPrice * $qty * ((100 -
$discount)/100);

$output .=
'<tr>' .
'<td>' . $row['saleID'] . '</td>' .
'<td>' . $row['itemNumber'] .
'</td>' .
'<td>' . $row['customerID'] .
'</td>' .
'<td>' . $row['customerName'] .
'</td>' .
'<td>' . $row['itemName'] . '</td>'
.
'<td>' . $row['saleDate'] . '</td>' .
'<td>' . $row['discount'] . '</td>' .
'<td>' . $row['quantity'] . '</td>' .
'<td>' . $row['unitPrice']

. '</td>' . '<td>' .
}
$totalPrice . '</td>' .

'</tr>';

$saleDetailsSearchStatement->closeCursor();

17
$output .=
'</tbody>
<tfoot
>
<t
r> <th>Total</th>
<th></th>
<th></th>
<th></th>

18
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>

</tr>
</
tfoot>
</table>';
echo
$output;
?>

19

You might also like