Not to sure my error is. In my html I have a form, and when I click submit it gives me an error. My connection is working, but for some reason it won't actually add to the database
<?php
if( isset( $_POST['submit'] ) ){
$username = $_POST['username'];
$password = $_POST['password'];
$connection = mysqli_connect( 'localhost', 'root', '', 'loginapp' );
if($connection){
echo "we are connected";
}
else{
die( "connection failed" );
}
$query = "INSERT INTO users(username,password) ";
$query.= "VALUES('$username','$password')";
$result = mysqli_query( $connection, $query );
if( !$result ){ // if not true, put query failed
die('Query Failed' .mysqli_error($connection));
}
}
?>
I am wondering if there is something wrong with this here as this code isnt working as planned
$query = "INSERT INTO users(username,password) ";
$query.= "VALUES('$username','$password')";
$result = mysqli_query( $connection, $query );
if( !$result ){ // if not true, put query failed
die( 'Query Failed' . mysqli_error( $connection ) );
}
}
usernamecolumn. You cannot have duplicate values in that column, or anyuniquecolumn.