-2

I want to prevent duplication of data when inserting. this is my code and its not working, I just want to know how to code this properly

<input type="text" name="text" id="text" readonyy="" autocomplete="off" placeholder="Type here for manual inserting" class="form-control" formaction="insert.php" value="<?php if(isset($errors['name'])) echo $errors['n']; ?>" required>

<button type="submit" class="btn btn-success">Insert Name</button>
$name = $_POST['name'];

        $errors = array();

        $n = "SELECT NAME FROM table_attendance WHERE NAME='$name'";
        $nn = mysqli_query($conn,$n);

        if (empty($name)) {
            $errors['n'] = "Value is needed to proceed";
        }elseif (mysqli_num_rows($nn) > 0) {
            $errors['n'] = "This Person already scan his/her QR Code";
        }

        header("Location: index.php");

I want to know how to code this properly

1 Answers1

-1
  1. Check $_POST['name'] before accessing it if(isset($_POST['name'])
  2. Your inputs name is defined as "text". check it out too

p.s. this my first answer on SO)