News:

Wondering if this will always be free?  See why free is better.

Main Menu

Trying to code a pop-up login box.

Started by Wellwisher, May 02, 2017, 01:21:58 PM

Previous topic - Next topic

Wellwisher

Hello

I am trying to code a pop-up login box inside a <div>. I coded the html login text/field boxes but when I enter username and password, smf doesn't allow me to login, instead redirects me to the search page...

In this pop-up box is where I am attempting to code the login box:



Any theme that does something similar or if anyone can provide me with easy to use code snippet. I tried looking around, and reviewed this post but the code only works when you stick it after function template_body_above():
http://www.simplemachines.org/community/index.php?topic=446545.0

Any help would be much appreicated?


Wellwisher

Quote from: Shambles on May 02, 2017, 01:36:56 PM
Have a look at how snrj does it...

https://custom.simplemachines.org/mods/index.php?mod=3885

Nice one, I should be able to figure this out now (fingers crossed).  Thanks Shambles. :)

I think my login box isn't working because of the codes placement.

Arantor

You've probably positioned the login <form> inside the search <form>.

Wellwisher

Quote from: Arantor on May 02, 2017, 05:16:25 PM
You've probably positioned the login <form> inside the search <form>.

Dude sort of.

After tinkering, I found that this line was the culpert and as a result, the login kept being redirected to the search page:

<form class="navbar-form" action="', $scripturl, '?action=search1" role="search" method="post" accept-charset="', $context['character_set'], '">

So now is the case of re-arranging everything. #sadpandamoments :-[

Arantor

So you did have the login form inside the search form, meaning that the search form would take priority.

Wellwisher

Quote from: Arantor on May 02, 2017, 06:15:03 PM
So you did have the login form inside the search form, meaning that the search form would take priority.

Just checked my coding mess. Yes this was the case so how do I break this cycle, or is it going to be the case of re-arranging everything?

Here's my code snippet from index.template.php:



function template_body_above()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;

echo '
<div id="header">
<div class="wrapper">
<a id="logo" href="'.$scripturl.'"></a>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">

<!-- RESPONSIVE SEARCH -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">

<form class="navbar-form" action="', $scripturl, '?action=search1" role="search" method="post" accept-charset="', $context['character_set'], '">

<div class="input-group">
<div class="box">
<a class="button" href="#popup1">Log in</a>
</div>

<div id="popup1" class="overlay">
<div class="popup">
<a class="close" href="#">&times;</a>
<div class="content">





<form id="guest_form" action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
<div id="box-login-top">
<label for="popupwindows">', '</label>
</div>
<input type="checkbox" id="popupwindows" name="popupwindows"/>
<label class="popupwindows">
<div class="info">',$txt['login_or_register'],'</div><br>
<fieldset>
<input id="username" name="user" placeholder="username" class="form-text" type="text">
</fieldset>
<fieldset>
<input id="password" name="passwrd" placeholder="password" class="form-text" type="password">
</fieldset>
<input type="submit" value="', $txt['login'], '" class="button_submit" />
<input type="hidden" name="hash_passwrd" value="" />
</label>
</form>








</div>
</div>
</div>


Kindred

if it's a pop-up, then put the code into a function... and drop the function call ANYWHERE in the template EXCEPT in the middle of the search form
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Wellwisher

Quote from: Kindred on May 02, 2017, 06:29:20 PM
if it's a pop-up, then put the code into a function... and drop the function call ANYWHERE in the template EXCEPT in the middle of the search form

Roger that. Thanks for the assistance Kindred. Love you all.

Advertisement: