The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
custom login page - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23) +--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26) +--- Thread: custom login page (/showthread.php?tid=1079) |
custom login page - roger - 06-21-2018 Hi! ...I'm a noob. but the installation was easy and userspice is running of course. Everything works. What I would like to do, is create a custom user page for each user. They don't really differentiate much, but I would need to transfer a variable (username) to a form respectively when the form is submitted the username automatically in there. This is how the form works right now: ==== <form class="form-horizontal" role="form" id="test-form"> <div class="form-group"> <label class="col-lg-3 control-label">First Name</label> <div class="col-lg-3 inputGroupContainer"> <div class="input-group"> <input type="text" class="form-control" name="firstName" placeholder="First Name"/> </div> </div> </div> ==== So ideally I have a hidden form field that gets the username or full name through the login procedure. I can then submit the form without the user having to input anything. Any help is greatly appreceated. R. custom login page - mudmin - 06-21-2018 So if the user is logged in, you already have access to the user's username in the variable $user->data()->username; If you want them to physically go to a different page, you can do that in usersc/scripts/custom_login_script I guess the question is what do you want to do with the page? custom login page - roger - 06-21-2018 well, after logging in they should see a page (or section for that matter) with a form. On submit each individual user should have their username / name submitted. custom login page - mudmin - 06-21-2018 Ok, so I think you're thinking about that wrong. Once someone is logged in, you have the entire user object at your disposal. In fact, try this... Go on a page where the user is logged in. Any page and add this code... Code: <?php Code: if(isset($user) && $user->isLoggedIn()){ Code: dump($user); Code: } Code: ?> You don't need that isset part, but what it does is stops the page from throwing a bunch of errors if the user isn't logged in. So, once you have all that information, you can just call it by doing Code: $user->data()->fname Code: $user->data()->email So on submit, you would just do Code: if(!empty($_POST){ Code: $username = $user->data()->username; Code: } custom login page - roger - 06-22-2018 Thanks, Mudmin I added the lines in the account.php - which essentially has the user information since after login. this one <?php if(isset($user) && $user->isLoggedIn()){ dump($user); } ?> didn't render the site correctly. this snippet: $user->data()->fname - seems to be working fine (no render errors) and this one: if(!empty($_POST){ $username = $user->data()->username; } I don't know how to work :/ sorry custom login page - roger - 06-22-2018 got it work like this: <input type="text" class="form-control" name="user" value="<?=echouser($user->data()->id)?>"/> custom login page - mudmin - 06-22-2018 Yes. That works. The thing you risk is that someone could change it. If it were me, I would try 2 more things. I would add the word readonly to the end of the input Code: <input type="text" name="user" value="<?=$user->data()->id?>" readonly> but then, to be honest, if on form submission I would not even look at what's inputted on the form input. I would just do Code: $username = $user->data()->username; Unless you really want them to be able to put something other than their username in there, because even with readonly, they could post a different username (like admin). |