View previous topic :: View next topic |
Author |
Message |
deerdork
Joined: 09 Feb 2003 Posts: 12
|
Posted: Fri Feb 14, 2003 5:22 am Post subject: login on main page... |
|
|
how do i make the actual login form be on the main page...
i tried copying the php and login section of b2login.php and pasting it on the main page...but it threw back errors because it didnt expect that new php to be there...
and when i took that away expecting the form to still work since the action is still set to b2login.php but it still didnt work....
it would be much more conveniant to have the login on the main page...
is there any way this can be done?
thanks in advance |
|
Back to top |
|
 |
macshack
Joined: 17 Jul 2002 Posts: 1204 Location: Phoenix, Az
|
Posted: Fri Feb 14, 2003 7:45 am Post subject: |
|
|
Hi,
So see if I understand. You want the "login" form on the main template so that the viewer does not have to go to a seperate page to login. Is that correct?
And if the login fails, where does he/she end up. The existing login page or somewhere else? _________________ Kind Regards,
Michael e |
|
Back to top |
|
 |
deerdork
Joined: 09 Feb 2003 Posts: 12
|
Posted: Fri Feb 14, 2003 11:21 pm Post subject: |
|
|
yes the login on the main page...
and if the login fails then they would be redirected to the b2login.php page... |
|
Back to top |
|
 |
Muse
Joined: 05 Mar 2003 Posts: 6 Location: New York, NY
|
Posted: Wed Mar 05, 2003 8:40 pm Post subject: Want to put tableless login form on index page |
|
|
I was sure hoping this question had been answered.
I'd like to add a login form to my main "index.php" page also, but I don't want to use tables. I want to put it in a div.
Can someone please help me with the code??? Thanks in advance!  _________________ Muse |
|
Back to top |
|
 |
macshack
Joined: 17 Jul 2002 Posts: 1204 Location: Phoenix, Az
|
Posted: Thu Mar 06, 2003 8:21 am Post subject: |
|
|
Hi,
How about something like:
Code: |
<div>
<form name="" action="b2login.php" method="post">
<?php if ($mode=="bookmarklet") { ?>
<input type="hidden" name="mode" value="<?php echo $mode ?>" />
<input type="hidden" name="text" value="<?php echo $text ?>" />
<input type="hidden" name="popupurl" value="<?php echo $popupurl ?>" />
<input type="hidden" name="popuptitle" value="<?php echo $popuptitle ?>" />
<?php } ?>
<input type="hidden" name="redirect_to" value="b2edit.php" />
<input type="hidden" name="action" value="login" />
<table width="180" style="background-color: #ffffff" border="0">
<tr><td align="right">login</td>
<td><input type="text" name="log" value="" size="8" /></td></tr>
<tr><td align="right">password</td>
<td><input type="password" name="pwd" value="" size="8" /></td></tr>
<tr><td> </td>
<td><input type="submit" name="Submit2" value="OK" class="search"></td></tr>
</table>
</form>
</div
|
Style attributes could be added to complete this. But this works. If the ID/PW are wrong, you go back to the standard b2login.php page. _________________ Kind Regards,
Michael e |
|
Back to top |
|
 |
dtdgoomba
Joined: 05 Aug 2002 Posts: 179 Location: Cambridge, MA
|
Posted: Thu Mar 06, 2003 3:07 pm Post subject: |
|
|
I just did this on my site http://www.goombalooza.com. I also have it, since someone suggested it, to not always display the login if you're already logged in so I thought I'd post that here:
Code: |
<?php
$logincookie = $_COOKIE['cafeloguser'];
if(!isset($_COOKIE['cafeloguser']) || $_COOKIE['cafeloguser'] == '') {
?>
Your login form goes here, straight html like what macshack wrote
<?php } else { ?>
<a href="<?php echo $siteurl; ?>/b2edit.php"><?php echo $logincookie; ?> is logged in, click here to post!</a>
<br /><br />
<a href="<?php echo $siteurl; ?>/b2login.php">Click here if you are not <?php echo $logincookie; ?></a>
<?php } ?>
|
If the person isn't logged in, you get the form, if the person is, they get 2 links (obviously format it to what you want ):
username is logged in, click to post! <- brings them to b2edit.php
click here if you're not username <- brings them to b2login.php |
|
Back to top |
|
 |
macshack
Joined: 17 Jul 2002 Posts: 1204 Location: Phoenix, Az
|
Posted: Thu Mar 06, 2003 5:11 pm Post subject: |
|
|
dtdgoomba, Nice touch. Maybe this ought to become a template fuction go 'build' this on the page with a call something like <?php login_form() ?>.
Thoughts? _________________ Kind Regards,
Michael e |
|
Back to top |
|
 |
dtdgoomba
Joined: 05 Aug 2002 Posts: 179 Location: Cambridge, MA
|
Posted: Thu Mar 06, 2003 9:59 pm Post subject: |
|
|
Definitely, I'll do that when I get a chance today/tomorrow and post it in hacks. Just as a matter of 'proper' hacks, should I tell people to put this into b2functions.php at the end?
When it is up in hacks, I'll post the link here as well to point people |
|
Back to top |
|
 |
macshack
Joined: 17 Jul 2002 Posts: 1204 Location: Phoenix, Az
|
Posted: Thu Mar 06, 2003 10:10 pm Post subject: |
|
|
b2template.functons.php is the correct place. Think about style sheet needs and desires as you prepare this. Embeding the HTML was the only downside I could think of with this approach. But in general I think its worth while. _________________ Kind Regards,
Michael e |
|
Back to top |
|
 |
dtdgoomba
Joined: 05 Aug 2002 Posts: 179 Location: Cambridge, MA
|
Posted: Sun Mar 09, 2003 8:28 pm Post subject: |
|
|
Just out of curiousity, what should be put into the template functions and what into b2functions? My friend had put everything into b2functions so I wasn't sure. But I'll make sure this hack goes into the right one like you said...
Another question. the cookie that gets left points to your siteurl correct? I have the login feature working if you're in my b2 directory, but on the main page, it doesn't work and I'm guessing b/c the cookie doesn't point to the root directory...? I'm just starting to learn about cookies so I was just wondering if anyone knew. I just noticed it yesterday. |
|
Back to top |
|
 |
macshack
Joined: 17 Jul 2002 Posts: 1204 Location: Phoenix, Az
|
Posted: Mon Mar 10, 2003 4:43 am Post subject: |
|
|
Those functions that deal with "template" functionality go in b2template.functions.php. These either dirtectly or indirectly drive stuff to the output page.
Things that are a part of the core functions of b2 go in b2functions.php. These could be thought of as "service" items that implement the behavior of b2.
The above is a "general" guidline. And in fact most hacks should not go in either file. They should be in seperate files to allow for ease of updating to the next release. Obviously, if the "hack" needs to change one of the b2 functions, then they need to be modified (in most cases.) But if the functionality can be implemented by "replacing" existing functions with new functions and names, then those should go in a new file. For example, if I was doing a special list_cats() template function, then it would generally be better to name this function my_list_cats() and place it in a new file and include that at the top of the template page along with blog.header.php. Again, this is for ease of upgrade to the next release. Otherwise, your going to be required to move those changes into the new code by hand.
The cookies, by default, should be set for the domain and should not be affected by the placement of the login form or b2. This can be an issue with those trying to use multiple copies of b2 and have a different login user/password for them. _________________ Kind Regards,
Michael e |
|
Back to top |
|
 |
dtdgoomba
Joined: 05 Aug 2002 Posts: 179 Location: Cambridge, MA
|
Posted: Mon Mar 10, 2003 6:37 am Post subject: |
|
|
Yeah, I know it's all supposed to be includes.. since on my one site, i'm going to upgrade it for a while, I just hack it up, but I'm trying to get the correct methodology done to help people here.
anyway, I found out what was going on with my blog. The cookies in b2login.php and ak's b2lastvisit.php are called for from my main page and subdirectory b2. I noticed the cookies don't define a path (not in the version I have). I included the path after seeing what michael park changed in the 'since last visit' hack. he put his path and domain name. To get my above code working on any page in the site, I had to change the set_cookie() functions for the b2login (b/c it stores the user and pass) and the lastvisit.
In my b2login.php, i found everywhere it said setcookie and changed it
ie:
Code: |
setcookie("cafeloguser",$user_login,time()+31536000,"/",".goombalooza.com");
|
When I did that to every instance, I have the cookies pointing to the root and now it all finally works!! It'll say I'm logged in on every page now.
Question though: I'm not running the newest version of this particular site but should b2 set the cookie to include path and domain like that? maybe be a setting in the config file? or does the newest version have that already? I'm open to any opinions here or maybe this should be moved now to a new thread.... |
|
Back to top |
|
 |
macshack
Joined: 17 Jul 2002 Posts: 1204 Location: Phoenix, Az
|
Posted: Mon Mar 10, 2003 7:49 am Post subject: |
|
|
The http standards do not require it and if not done correctly could add further confusion. In most usages a specific directory or domain/subdomain are not required in the use of cookies. That's not to say that there is not a case for when there could be.
A case that makes sense for specifing the domain and path is when there are two blogs in the domain. Then it would make good sense to tie the path to the cookie. But just think about that. If the index page is not in the same location as the b2 files, what to we put as the path? If the path is the index.php location, then there may be cases (login for example) where the page is in a diffenent directory and thus the cookie would not match. It just gets a little complicated.
So I would recommend not to specify the directory path or domain unless there is a good reason to do so. _________________ Kind Regards,
Michael e |
|
Back to top |
|
 |
dtdgoomba
Joined: 05 Aug 2002 Posts: 179 Location: Cambridge, MA
|
Posted: Mon Mar 10, 2003 2:17 pm Post subject: |
|
|
Ok, I understand. I wasn't sure if it was a standard or not to specify it after I looked up the function on php.net. In this case, it had to be specified. I noticed the 2 cookies getting saved for 'lastvisit' and the login was specifying /b2/ until I changed it to root. Then the login cookie was ok. Thanks for getting back to me macshack. I'm getting the hang of this now and can move on to my next php lessons |
|
Back to top |
|
 |
dtdgoomba
Joined: 05 Aug 2002 Posts: 179 Location: Cambridge, MA
|
|
Back to top |
|
 |
|