- If you are using mySQL and want just the auto_increment field value to be returned, you can use the mysql_insert_id() function.
$connection = mysql_connect("localhost", "","");
$query = "INSERT INTO user(login,password) VALUES('username', 'password') ";
$result = mysql_query($query, $connection);
print("Auto increment is " . mysql_insert_id($connection));
- $query = "SELECT username FROM users WHERE username = 'john' ";
$result = mysql_query($result,$connection);
$row = mysql_fetch_array($result);
if($row != "")
{
print("The username exists!");
}
else
{
print("The username is available.");
}