Skip to content

Instantly share code, notes, and snippets.

@ZaeemSattar
Created November 25, 2016 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZaeemSattar/16f1cab0606f8407809345c79bfc2a90 to your computer and use it in GitHub Desktop.
Save ZaeemSattar/16f1cab0606f8407809345c79bfc2a90 to your computer and use it in GitHub Desktop.
<?php
$conn = new mysqli("localhost", "example", "password", "yourDB");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$name=$_POST["username"];
if(isset($_POST["username"]))
{
$sql ="INSERT INTO User (username) VALUES('$name')";
$result=$conn->query($sql);
$id = mysqli_insert_id($conn);
echo $id;
}
else
{
echo 'connection error';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment