The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Single page application's popups & functionality integration
#1
Hello,
I have a single page application (bootstrap based) which uses modals / popups for login, registration and forgot my password.
I tried to understand how to integrate the userspice's functionality into those popups instead of moving my page to new URL, but the default use of separate page / php file prevented me from achieving that integration.

HELP! how it can be done?

Thank you!
  Reply
#2
Hey,
I'm not a pro but my thoughts might help you:

As long as UserSpice uses a PHP-Validation Class and stuff like csrf-tokens, you probably have to use Ajax. As you might have seen, putting login, register and forgot password together in index.php, will cause some php spaghetti. To keep structure and functionality you need JSON aswell.

Example Page: 'login.php'

Without Ajax, the page will get a hard refresh after the submit button is clicked. The php gets executed and validates the input. If the input is invalid, the modal will broke. The error message will be displayed.

With Ajax, login.php will be executed in "background". You're modal won't break, but the action is taking place in "login.php". So, if users input is invalid, you need JSON to get the variables back. With some js and jquery skills it should be possible to not break the site.

Just for security and usability i would keep them by their own path. But that's my opinion. What you can also do:

index.php
->login modal with <form action="login.php"/>
->if validation->passed = Log User in (set in login.php)
->if validation not passed -> Redirect to login.php />

index.php
->register modal with <form action="join.php"/>
->use some live jquery to be sure that user fills out everything and correctly
->if validation->passed = Redirect to success page
->if validation not passed -> Redirect to join.php />

You need to split the validation php from the html form stuff and possibly rename inputs for clarity.

Maybe that helps. Regards from Germany
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)