Here is the code that I've used
html:
<form action = 'insert.php' method='POST'>
<input type = "text" name = "name">
<input type = "submit" name = "submit">
</form>
php:
<?php
$servername='localhost';
$username='noob';
$password='password';
$conn = mysqli_connect($servername, $username, $password);
if (!$conn)
die("Connection failed: " . mysqli_connect_error());
$a=$_POST['name'];
mysqli_query("INSERT INTO table1 (name) VALUES ('$a')");
?>
Right now, the code above inserts a name into a table called table 1. My question now is, say I input many names into the table, but I want each name to have a unique 6 character/digit id. How would I change this code? For example, after 3 inserts, the table should look like this:
[table 1]
name unique_id
NAME1 994323
NAME2 832344
NAME3 332123
Each value of unique_id
must be unique. Is there any efficient way to do this?