Login status in custom file

Hello. How to include system configuration for my custom application? (v2022)
I included this file but have errors.

<?php $RELATIVE_PATH = "api/";  require_once "api/vendor/autoload.php"; ?>
<?php 

if (!IsLoggedIn()) { header("Location:  http://xxx/api/login");
	die();
}

Fatal error: Uncaught Error: Call to undefined function PHPMaker2022\men\IsLoggedIn() in D:\OpenServer\domains\xxx\index.php:15 Stack trace: #0 {main} thrown in D:\OpenServer\domains\xxx\index.php on line 15

You may read Custom File → How to Use:

  • Include common files
  • Path

If you want to use PHPMaker global functions such as IsLoggedIn(), you should use “Include common files”. No need to include autoload.php yourself.Also read https://discourse.hkvstore.com/t/using-route-action-server-event-v2021/3393/1

I have Errors for generation custom files.Error: The content of the Custom File ‘one’ is empty.

As the error said, you need to add some content. If no content, there is no need to use Custom File at all. If you just want to add some code, read https://discourse.hkvstore.com/t/using-route-action-server-event-v2021/3393/1

How can I to use Forms in my custom files?I built my form but when I go request I see this Error.

<form method="post" enctype="multipart/form-data">
<input type="text" value="" name="amount">
<input type="text" value="" name="month">
<input type="submit" value="go" name="btn">
<input type="hidden" value="1" name="hash">

</form>

400
Bad Request
The server cannot or will not process the request due to an apparent client error.

You may refer to the generated code of Add and/or Edit page. See the related file in the generated views sub-folder.

I’ve hit exactly the same problem. Did you find a solution?I’m inspecting the code for a generated Add and Edit page for clues, but I don’t understand the constructionI’m just testing a form with minimal functionality, to try to get it working at all but i still get error 400 on submit.

<form method="POST" class="ew-form ew-edit-form" action="<?= CurrentPageUrl(false) ?>" novalidate autocomplete="off" id="fFieldEncrypt" name="fFieldEncrypt">
<input type="hidden" name="action" id="action" value="update">
    
	<button class="btn btn-primary ew-btn" name="btn-action" id="btn-action" type="submit" form="fFieldEncrypt">Submit</button>
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['submit_btn'])) {
    echo "hello";
}
?>

there must be some essential required elements missing, but I can’t figure out what.
Some more help on this would be appreciated.

You better search “Check token for form post” in this forum and in the docs.