Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: zmc on August 25, 2014, 10:16:28 AM

Title: SMF 2.0.8 Login
Post by: zmc on August 25, 2014, 10:16:28 AM
Hi,

Sorry, I speak a little english. My SMF Forum installed: ~/forum/*.*

I would like login page the ~/index.php


<?php
if ($login === true) {
header ( 'location: http://localhost/forum/index.php' );
} else {
if (
$_POST['login']) {
if (
$_POST['username'] & $_POST['password']) {// if the user data is correct from the SMF mysql db
header( 'location: http://localhost/forum/index.php' );
} else {
// if not correct user data
print 'error';
}
} else {}
print
'Login form: <form method="post"><input type="text" name="username"><input type="password" name="password"><input type="submit" name="login"></form>';
}
?>


Please help me & write a code this simple login form.

Thanks! Have a nice days!
Title: Re: SMF 2.0.8 Login
Post by: Arantor on August 25, 2014, 01:26:06 PM
I don't quite understand what you want to do.

But it seems to me you want ssi_login(), as per SSI Readme (http://wiki.simplemachines.org/smf/Category:SSI) and How do I integrate SMF into my PHP coded website? (http://wiki.simplemachines.org/smf/How_do_I_integrate_SMF_into_my_PHP_coded_website) and How to use the SMF user system outside of SMF (http://wiki.simplemachines.org/smf/How_to_use_the_SMF_user_system_outside_of_SMF)
Title: Re: SMF 2.0.8 Login
Post by: zmc on August 25, 2014, 03:42:10 PM
It works! My forum is private forum. See only registered users after login. Not see guests.

http://localhost/forum/Settings.php


<?php

$ssi_guest_access = true;


http://localhost/index.php


<?php

require_once(
"forum/SSI.php");
if ($context['user']['is_logged']) {
header ( 'location: http://localhost/forum' );
} else {
print '<form method="post" name="login">';
}

?>


How to change the login form page is redirect to http://localhost/index.php (login form)

I would like, If not login all http://localhost/forum/* pages redirect to http://localhost/index.php the login form.
Title: Re: SMF 2.0.8 Login
Post by: zmc on August 26, 2014, 04:56:19 AM
Please help me!

Guests are not see the forum. I would like see the guests are only all-time login page: http://localhost/index.php (login form)
Registered users are see the forum after login. http://localhost/index.php (login form) -> http://localhost/forum/index.php (main page of SMF forum)

I would like the guests are all time see the login page http://localhost/index.php (login form).

Very sorry my bad english.
Title: Re: SMF 2.0.8 Login
Post by: Hj Ahmad Rasyid Hj Ismail on August 26, 2014, 05:16:06 AM
Admin > Config > Feature. Untick allow guest to browse.
Title: Re: SMF 2.0.8 Login
Post by: zmc on August 26, 2014, 05:51:15 AM
Quote from: ahrasis on August 26, 2014, 05:16:06 AM
Admin > Config > Feature. Untick allow guest to browse.

Yes, it's ok, it is my settings. I would like guests (not login users) are:

http://localhost/forum/index.php -> http://localhost/index.php (login form)
http://localhost/forum/index.php?action=help -> http://localhost/index.php (login form)
http://localhost/forum/index.php?action=search -> http://localhost/index.php (login form)
http://localhost/forum/index.php?action=login -> http://localhost/index.php (login form)
http://localhost/forum/index.php?action=register -> http://localhost/index.php (login form)
http://localhost/forum/index.php?action=credits -> http://localhost/index.php (login form)
http://localhost/forum/index.php?wap2 -> http://localhost/index.php (login form)
http://localhost/forum/index.php?action=reminder -> http://localhost/index.php (login form)
http://localhost/forum/* -> http://localhost/index.php (login form)

I would like private forum. Not registering, only invite.
Title: Re: SMF 2.0.8 Login
Post by: Hj Ahmad Rasyid Hj Ismail on August 26, 2014, 06:05:48 AM
Then disable registration as well. Admin > Members > Registration > Settings. Select Registration Disabled in the dropdown. This will totally disable registration while you configure a mod to enable invitation. You can find it at the mod page. This one can be useful: http://custom.simplemachines.org/mods/index.php?mod=2567
Title: Re: SMF 2.0.8 Login
Post by: zmc on August 26, 2014, 06:08:12 AM
Quote from: ahrasis on August 26, 2014, 06:05:48 AM
Then disable registration as well. Admin > Members > Registration > Settings. Select Registration Disabled in the dropdown.

Ok, but the redirectings are how to? All $_SESSION [ 'login' ] is FALSE then http://localhost/forum/* forwarding to http://localhost/index.php (login form this).
Title: Re: SMF 2.0.8 Login
Post by: Hj Ahmad Rasyid Hj Ismail on August 26, 2014, 06:31:18 AM
Quote from: ahrasis on August 26, 2014, 05:16:06 AM
Admin > Config > Feature. Untick allow guest to browse.
This already cover all that. That's a basic SMF settings. All menu link will only display login form.

Plus, I am not sure why the moderator is merging your topics. It kinda confusing now as I am not dealing with your coding or anything.

As for SSI, that is something I am not very familiar with. Wait for Arantor or others to reply.