Php: Setting the index extension to php and adding, keeping code


#1

Because I need to keep session vars, make validation and insert php values, have been manually writing a php code wrap on the generated index.html from appstudio.
It works fine until I need some modification.
Question: is there a way to permanently keep my php tags and code, and likewise make the generated index a php extension instead of hrml?


#2

I’m not sure I understand what you’re doing here.

You can have .php files as Code Modules. Have a look at the Ajax sample.


#3

Sorry I didn’t specify. The target is for website deployment on a local folder ( I place it on the actual website via FTP).
Whenever I create a project and export it to local folder, the starting file is index.html.

Since I am calling this index from another website php script (part of an existing php web application) where the user has authenticated and has a php session where variables can be passed without using form action:

a) I rename the index.html to index.php.
b) i write some php code inside index.php. Code is for authentication, redirection to error pages, and also for echoing php values, among other things.

The problem is that if I make some changes to the appstudio project, when i export it I have to do the changes manually again, every time.

That is why I was asking if:

  1. instead of index.html, appstudio could export an already named index.php.
  2. Instead of editing that index.php by hand everytime, my code could be part of the appstudio project so when it exports I don’t have to change any of it by hand every time.

Thanks,
JD


#4

No, this isn’t possible with the way AppStudio works right now. You’ll need to find another way to do this.


#5

JD, from inside NSBasic Project, create a ajax call to your php code for authenticator. After this continue with your nsbasic project.


#6

If you have access to your .htaccess file on the target server where the application lives it is possible, I seem to recall there is a way to write a server-side directive to run .htm and .html files as php. It’s been a while since I’ve tried it but it actually worked. The other option is to request you server admin or host to do this for you.

If you are using authentication, you can also use Volt as an authentication server. Volt uses a claims based approached. In this case, it is JWT aka JSON Web Tokens. This will also avoid you having to keep track of sessions and allows login from a compiled iOS or Android app which doesn’t allow for sessions.


#7

Hi guys, thanks for your useful tips.