Proceed Transaction if card number is found in the database?

≯℡__Kan透↙ 提交于 2020-01-11 14:06:06

问题


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>

来源:https://stackoverflow.com/questions/59517523/proceed-transaction-if-card-number-is-found-in-the-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!