CMS Made Simple Forums
https://forum.cmsmadesimple.org/

​ Going back to FEU protected form after login process UDT
https://forum.cmsmadesimple.org/viewtopic.php?f=4&t=76743
Page 1 of 1

Author:  jakovbak [ Fri Jun 16, 2017 11:11 am ]
Post subject:  ​ Going back to FEU protected form after login process UDT

​A quick description of the situation:
A page contains FEU protected contact form. To access such form, already registrated user must log in to site. Clicking on 'Log in' link opens up a new page with log-in form. That's one step away from desired contact form.
After entering proper username and password and clicking on 'Submit' button, a new page opens up containing two links by default: 'Change user settings' and 'Sign out'. That's second step away from desired contact form.

The Problem:
I needed another link called 'Back to form' and solution for taking an user two pages back while reloading the page where 'Log in' link was initially clicked.

The Solution:
With help of my friend who diggs php, we did the following...
1) create first UDT called "remember_form" with following code:
Code:
session_start();
$page = $_SERVER["REQUEST_URI"];
$_SESSION['page'] = $page;

2) put first UDT in every template for page(s) containing FEU protected form(s) right after {/strip} at the top of the template;
3) create second UDT called "back_to_form" with the following code:
Code:
session_start();
echo "http://".$_SERVER['SERVER_NAME'].$_SESSION['page'];

4) open template 'FEU logout form' (or whatever your template is called but containing the same code as in original FEU template) and put this link where you think it would be most visible or useful:
Code:
<a href="{back_to_form}">Back to form</a>

And that's it! After logging in to the site, "Back to form" link will take one back to the page where desired form is but this time the form itself will be unlocked and visible.

Now, I'm not security wizard so I don't know if this solution is 100% safe. If anyone suspects this two UDT's could cause some security issues, please, you're more than welcome to leave a post about it in reply!

Hope this was helpful and best regards to all!
Jakovbak

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/