function create(){
//If linking to database from external file
global $connection;
//Grab form data
$username = $_POST['username'];
$password = $_POST['password'];
//Sanatize user input
$username = mysqli_real_escape_string($connection,$username);
$password = mysqli_real_escape_string($connection,$password);
//Query that inserts value into database
$query = "INSERT INTO users(username,password) ";
$query .= "VALUES ('$username', '$password')";
$result = mysqli_query($connection,$query);
if(!$result){
die('Query failed' . mysqli_error());
}
}
//HTML FILE
if (isset($_POST['submit'])) {
create();
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter