0
<!DOCTYPE html>
<html>
<body>
<h1> Welcome to my game!</h1>

<form action="gameBrandGuess.php" method="post">
<label for="Name">Enter Your Name:</label>
<input type="text" name="aName" id="$fullName">
<input type="submit" value="Submit">

</form>
</body>
</html>





<!DOCTYPE html>
<html>
<body>
<?php

$servername = "localhost";
$username = "user";
$password = "mydb";
$dbname = "GameDb";

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo $_POST["aName"];
$sql = "INSERT INTO Statistics (Name)
 VALUES ('$fullName');"

if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}


$conn->close();
 ?>
</body>
</html>

The code wont take the input from the form and store it into the database, I played around and I only got the code to post to the database but it comes out empty. I want the user to input their name and it be stored into the database that's it.

0 Answers0