QWGames
QWGames
KPCKevin Powell - Community
Created by QWGames on 12/21/2023 in #back-end
Unexpected end of json input
I am making a request to a php file, and the php file should send back a json encoded array, but I'm getting unexpected end of json input for some reason. Here is the JS and the PHP:
//Get Account Information
function GetAccountInfos()
{
fetch("account_functions.php?action=1", {
method: 'post',
headers: {
"Content-Type": "application/json"
}
})
.then(response => response.json())
.then(data => {
if (data !== null)
{
console.log(data);

document.getElementById('account_info_username').value = data["username"];
document.getElementById('account_info_website').value = data["website"];
document.getElementById('account_info_email').value = data["email"];
document.getElementById('account_info_realname').value = data["realname"];
}
})
.catch(error => {
console.error(error);
})
}
//Get Account Information
function GetAccountInfos()
{
fetch("account_functions.php?action=1", {
method: 'post',
headers: {
"Content-Type": "application/json"
}
})
.then(response => response.json())
.then(data => {
if (data !== null)
{
console.log(data);

document.getElementById('account_info_username').value = data["username"];
document.getElementById('account_info_website').value = data["website"];
document.getElementById('account_info_email').value = data["email"];
document.getElementById('account_info_realname').value = data["realname"];
}
})
.catch(error => {
console.error(error);
})
}
49 replies
KPCKevin Powell - Community
Created by QWGames on 12/12/2023 in #back-end
Headers already sent error PHP form
Why this form is causing "headers already sent error":
<div class="form-container upload">
<form class="default-form upload" action="upload-game" method="post" enctype="multipart/form-data">
<label for="title">Title: </label>
<input minlength="3" maxlength="40" type="text" name="title" required id="title" autocomplete="off"/>

<label for="description">Description <p style="color:rgb(208, 208, 208)">[optional]</p>:</label>
<textarea maxlength="2000" name="description" rows="4" cols="50" id="description" autocomplete="off"></textarea>

<label for="release_date">Release date: </label>
<input type="date" name="release_date" required id="release_date" autocomplete="off"/>

<label for="embed">Embed <p style="color:rgb(208, 208, 208)">[recommended size: 500x300] [optional]</p>: </label>
<input class="upload-btn" type="file" name="embed" id="embed" autocomplete="off"/>

<label for="browser_file">Playable <p style="color:rgb(208, 208, 208)">[ZIP, should contain an index.html file] [optional]</p>: </label>
<input class="upload-btn" type="file" name="browser_file" id="browser_file" autocomplete="off"/>

<label for="download_file">Downloadable <p style="color:rgb(208, 208, 208)">[should be a ZIP file] [optional]</p>: </label>
<input class="upload-btn" type="file" name="download_file" id="download_file" autocomplete="off"/>

<p style="color: white;">Note: All settings can be changed later.</p>

<button type="submit">Upload</button>
</form>

<div id="error_container" class="error-container"></div>
</div>
<div class="form-container upload">
<form class="default-form upload" action="upload-game" method="post" enctype="multipart/form-data">
<label for="title">Title: </label>
<input minlength="3" maxlength="40" type="text" name="title" required id="title" autocomplete="off"/>

<label for="description">Description <p style="color:rgb(208, 208, 208)">[optional]</p>:</label>
<textarea maxlength="2000" name="description" rows="4" cols="50" id="description" autocomplete="off"></textarea>

<label for="release_date">Release date: </label>
<input type="date" name="release_date" required id="release_date" autocomplete="off"/>

<label for="embed">Embed <p style="color:rgb(208, 208, 208)">[recommended size: 500x300] [optional]</p>: </label>
<input class="upload-btn" type="file" name="embed" id="embed" autocomplete="off"/>

<label for="browser_file">Playable <p style="color:rgb(208, 208, 208)">[ZIP, should contain an index.html file] [optional]</p>: </label>
<input class="upload-btn" type="file" name="browser_file" id="browser_file" autocomplete="off"/>

<label for="download_file">Downloadable <p style="color:rgb(208, 208, 208)">[should be a ZIP file] [optional]</p>: </label>
<input class="upload-btn" type="file" name="download_file" id="download_file" autocomplete="off"/>

<p style="color: white;">Note: All settings can be changed later.</p>

<button type="submit">Upload</button>
</form>

<div id="error_container" class="error-container"></div>
</div>
25 replies
KPCKevin Powell - Community
Created by QWGames on 12/7/2023 in #front-end
How to disable cache for a specific page?
I have a website where people can upload there games, and play them. Every game has an embed image what can be changed by the devs throught the dashboard. I don't want search engines to cache the embed images of the games to make it show always the updated image. Is there a way to do this with JavaScript or with PHP headers? Link: https://qwgamers.net
5 replies