On my website i have a submit form:
When i press this submit button the name is being saved on to my database, which is fine but i also want that button to take me to the homepage. Right now it take me to a page saying Fatal error like this
But when i press on the URL link and press enter it take me to the homepage. How can i redirect the page to homepage without selecting/pressing on the URL link and hitting enter? This is my code:
CODE:
<?php
require_once "library/connection.php";
$stmt = $conn->prepare("SELECT * FROM usernames ORDER BY scores DESC LIMIT 10");
function createLeaderBoard($stmt)
{
$stmt->execute();
$stmt->rowCount();
$data = $stmt->fetchAll();
foreach ($data as $row)
{
?>
<tr>
<td><?php echo $row['users']; ?></td>
<td><?php echo $row['Scores']; ?></td>
</tr>
<?php
}
}
if (isset($_POST["firstname"]))
{
$firstname = $_POST["firstname"];
$score = $_POST["score"];
$stmt = $conn->prepare("INSERT INTO `usernames` (`users`, `Scores`) VALUES ('" . $firstname . "','" . $score . "');");
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
}
?>
Hope my English is good and i also hope you can understand me. All the help will be appreciated :)