Login status in custom file

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
btrade
User
Posts: 357

Login status in custom file

Post by btrade »

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


arbei
User
Posts: 9434

Post by arbei »

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 viewtopic.php?f=18&t=49447.


btrade
User
Posts: 357

Post by btrade »

I have Errors for generation custom files.

Error: The content of the Custom File 'one' is empty.


arbei
User
Posts: 9434

Post by arbei »

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 viewtopic.php?f=18&t=49447.


btrade
User
Posts: 357

Post by btrade »

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.


mobhar
User
Posts: 11765

Post by mobhar »

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


philmills
User
Posts: 566

Post by philmills »

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 construction

I'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.


arbei
User
Posts: 9434

Post by arbei »

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


Post Reply