So, I have everything working, then I try to add the duplicate insertion prevention, and it all breaks. If someone could help me, that would be great! :)
index.php:
<?php
include('dbConfig.php');
?>
<!Doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="$1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Database Solution</title>
</head>
<body>
<?php
$barcode=$_POST['barcode']
$check=mysqli_query($conn,"select * from Barcodes where barcode='$barcode'");
$checkrows=mysqli_num_rows($check);
if(isset($_POST['save']))
{
$sql = "INSERT INTO Barcodes (barcode)
VALUES ('".$_POST["barcode"]."')";
if($checkrows>0) {
echo "barcode exists";
} else {
$result = mysqli_query($conn,$sql);
}
?>
<h2 align="center">Barcode Database</h2>
<style type="text/css">
.fieldset-auto-width {
display: inline-block;
}
</style>
<div class="form">
<form method="post" align="center">
<fieldset class="fieldset-auto-width">
<legend align="center">Enter Barcode:</legend>
<input type="text" name="barcode" size="35"><br/><br />
<button type="submit" name="save">Input</button>
</fieldset>
</form>
</div>
<p align="center">© 2018 Nathaniel</p>
</body>
</html>
dbConfig.php:
$conn=mysqli_connect("localhost","n****ec_**s","****","n******_***");
if(!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
?>
Is there a way I can fix this? I'm probably being dumb, but I hope that someone can help me fix this issue.