I am Practicing a bit about MySQL Database connections through php. However, i am encountering a bit of a problem. Because of Inserting the Actual Username and Password that the user inputted into the MySQL Database itself, only blank rows, or a row containing empty (ps. Its not NULL, just empty) data is being inserted in it. The following below is how I created the actual forms that the user has to input to.
<?php
session_start();
include("testconnect.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Page</title>
</head>
<body>
<style>
#signup-box{
margin:auto;
width: 300px;
padding: 30px;
background-color: grey;
}
</style>
<div id="signup-box">
<form method="POST">
<input style="width:100%" type="text" name="Username"><br><br>
<input style="width:100%" type="password" name="Password"><br><br>
<input type="button" value="Submit">
</form>
</div>
</body>
</html>
And this is how i declared my php mysql connections.
<?php
$conn=mysqli_connect('localhost','root','','practice') or die ("unable to connect to database");
$username1=mysqli_real_escape_string($conn,$_POST['Username']);
$password1=mysqli_real_escape_string($conn,$_POST['Password']);
$query="insert into usertable values('$username1','$password1')";
mysqli_query($conn,$query);
I am hoping that someone here can help me with this slightly small problem of mine.
Ps. Already looked for solutions everywhere but none of the solutions offered seems to solve the problem. Ps. Already checked the db connection but there seems to be no problem at all