내 웹 사이트에 제출 양식이 있습니다.
이 제출 버튼을 누르면 이름이 내 데이터베이스에 저장됩니다. 괜찮지 만이 버튼을 눌러 홈페이지로 이동하고 싶습니다. 지금은 이와 같은 치명적인 오류라는 페이지로 이동합니다.
하지만 URL 링크를 누르고 엔터를 누르면 홈페이지로 이동합니다. URL 링크를 선택 / 누르고 Enter 키를 누르지 않고 페이지를 홈페이지로 리디렉션하려면 어떻게해야합니까? 이것은 내 코드입니다.
암호:
<?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);
}
?>
제 영어 실력이 좋길 바라며 저도 이해할 수 있기를 바랍니다. 모든 도움을 주시면 감사하겠습니다 :)
이거 chnage
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);
}
...에
if (isset($_POST["firstname"])) {
$firstname = $_POST["firstname"];
$score = $_POST["score"];
$stmt = $conn->prepare("INSERT INTO `usernames` (`users`, `Scores`) VALUES ('" . $firstname . "','" . $score . "')");
if($stmt->execute()){
// redirect the user to homepage.php
header("Location: homepage.php");
exit();
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다