I am new here.
So, I am making a transaction page for our cashless RFID scanner system.
The system works by scanning the RFID card. Once scanned, the card number would appear and get searched in the database. The search feature already works but the problem now is, what are the codes needed to make it proceed once the card number is searched. Otherwise, the transaction will not proceed if the card number is not found in the system?
Screenshot of search page
Screenshot of code
<?php
if(isset($_POST['search']))
{
$card_number = $_POST['card_number'];
$connect = mysqli_connect("localhost", "root", "","transaction");
$query = "SELECT `card_number`, `first_name`, `last_name`, `department`,`address` FROM `accounts_list` WHERE `card_number` = $card_number LIMIT 1";
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
while ($row = mysqli_fetch_array($result))
{
$card_number = $row['card_number'];
$first_name = $row['first_name'];
$last_name = $row['last_name'];
$department = $row['department'];
$address = $row['address'];
}
}
else {
echo "Card Number not in the system";
$card_number = "";
$first_name = "";
$last_name = "";
$department = "";
$address = "";
}
mysqli_free_result($result);
mysqli_close($connect);
}
else{
$card_number = "";
$first_name = "";
$last_name = "";
$department = "";
$address = "";
}
?>
<!DOCTYPE html>
<html>
<head>
<title> PHP FIND DATA </title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form action="searchsystem.php" method="post">
Card Number:<input type="text" name="card_number"><br><br>
First Name:<input type="text" name="first_name" readonly="readonly" value="<?php echo $first_name;?>"><br><br>
Last Name:<input type="text" name="last_name" readonly="readonly" value="<?php echo $last_name;?>"><br><br>
Addess:<input type="text" name="addess" readonly="readonly" value="<?php echo $address;?>"><br><br>
Department:<input type="text" name="department" readonly="readonly" value="<?php echo $department;?>"><br><br>
<input type="submit" name="search" value="Find">
</form>
</body>
<p><a href='/Transaction/home.php' title='Frank Tank Scripts'><font color='#000000'>Back</font></a></p>
</html>