Created
November 25, 2016 17:07
-
-
Save ZaeemSattar/16f1cab0606f8407809345c79bfc2a90 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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