Below I have a simple form field. This field, has an INPUT next to "name your card" with a name='name'. Well, I want to be sure that people cannot duplicate the name that is entered into this, as it goes into my database and users are able to retrieve the information based on this name field. I'm having a tough time figuring out how to avoid duplicated names in this name='name' field. Any help would extremely appreciative.
Here is my home page
<div class="field class">
<form action='newlist.php' method='POST'>
Name Your Card <input class="ha" type='text' name='name' required/>
<textarea class="hello" type='text' name='one' placeholder=''></textarea> <p>
<textarea class="hello" type='text' name='two'></textarea> <p>
<input type='submit' value='create'/>
and here is the page that the home page form field is directed to
<?php
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "christmas";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql="INSERT INTO list (name, one)
VALUES
('$_POST[name]','$_POST[one]' , '$_POST[two]')";
if ($conn->query($sql) === TRUE) {
echo "We have successfully saved your name "; echo "Be sure to share your list, '"; echo $_POST['name'] ; echo "' with friends!";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>