I will paste the code below. Okay so I've benn trying to work with SQL in php connecting to a MySQL Database I have hosted on my own computer. I am trying to use an HTML form to get in info I need. But when I hit SUBMIT I don't get the output I was looking for. Any ideas why my code wont work?
Also, I am sorry if this is the wrong section, I am new to the forum, if this is the wrong section, can someone please point me to where i need to go? Thanks!
<html>
<form action="index.php" method="post">
<input type="text" name="username"><br>
<input type="text" name="password"><br>
<input type="submit">
</form>
</html>
<?php
$uname = $_POST[username];
$pword = $_POST[password];
$con=mysqli_connect('localhost', 'root2', '', 'first_db');
//Check conbnection
if(mysqli_connect_errno())
{
echo 'Failed to connect: ' . mysqli_connect_error();
} else{
$result = mysqli_query($con,"SELECT * FROM members
WHERE username=$uname");
while($row = mysqli_fetch_array($result))
{
echo $row['username'];
echo $row['password'];
echo $row['id'];
}
}