MyBB Community Forums

Full Version: Login 2 websites same time
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!

I've made a login modal form and want to use it such as after submit if I am logged to main website, I will be logged to mybb.

I think this is possible with ajax.

First action is login code of my website and second action is member.php. 
In other words, I want to know how to send same post data with two different actions.

Or setting with cookies, but I don't know how.
Well you don't actually want to send the same POST data with two actions, because as you said you want to login to MyBB ONLY if you're logged in to your main website first, which implies that your main login needs to validate the post data first. Once your main login validates the form input and verifies the user login, it should then send validated, condensed data to MyBB (AJAX is useful here, but you could technically use cURL or a variety of other libraries to accomplish this) where MyBB should then run its own user validation on the data submitted from your initial login verification. The reason for only submitting the data to one link in the chain at a time is, aside from much easier error solving, there's no point validating bad information twice. That's unnecessary strain on your server if both your main site and MyBB have to waste resources validating username "cc^!mF_3**()" when clearly your initial website should detect an invalid username and reject it before it even reaches MyBB.

The actual process of logging in to MyBB is extremely simple and involves setting 2 cookies and updating the sessions table, it's really the validation that is the trickier part in this instance. Lines 1695-1784 are MyBB's actual full login verification, though there are even simpler ways to force login the user. This just ensures all the proper hooks are run and all the ratelimiters/captcha/coppa are checked and whatnot.
Thanks for reply and yes, you right, but some functions is undefined. I included global.php in my script but receive this error after login:

Warning [2] Illegal string offset 'type' - Line: 10 - File: inc/config.php PHP 7.1.6 (Linux)
Warning [2] Illegal string offset 'database' - Line: 11 - File: inc/config.php PHP 7.1.6 (Linux)
Warning [2] Illegal string offset 'table_prefix' - Line: 12 - File: inc/config.php PHP 7.1.6 (Linux)
Warning [2] Illegal string offset 'hostname' - Line: 14 - File: inc/config.php PHP 7.1.6 (Linux)
Warning [2] Illegal string offset 'username' - Line: 15 - File: inc/config.php PHP 7.1.6 (Linux)
Warning [2] Illegal string offset 'password' - Line: 16 - File: inc/config.php PHP 7.1.6 (Linux)
Warning [2] Illegal string offset 'encoding' - Line: 80 - File: inc/config.php PHP 7.1.6 (Linux)

And in bottom page this:

Quote:
MyBB Internal Error

MyBB has experienced an internal error and cannot continue.
Error Type:MyBB Error (42)Error Message:Your board has not yet been upgraded. Please do so before attempting to browse it.
Please contact the MyBB Group for technical support.

Apparently $config was not an array and for my new page was needed to make thaht $config = array();

Now it's working with cookies.

Thanks for all help, much appreciate.
(2017-08-17, 07:36 AM)adi19 Wrote: [ -> ]Thanks for reply and yes, you right, but some functions is undefined. I included global.php in my script but receive this error after login:

Warning [2] Illegal string offset 'type' - Line: 10 - File: inc/config.php PHP 7.1.6 (Linux)
Warning [2] Illegal string offset 'database' - Line: 11 - File: inc/config.php PHP 7.1.6 (Linux)
Warning [2] Illegal string offset 'table_prefix' - Line: 12 - File: inc/config.php PHP 7.1.6 (Linux)
Warning [2] Illegal string offset 'hostname' - Line: 14 - File: inc/config.php PHP 7.1.6 (Linux)
Warning [2] Illegal string offset 'username' - Line: 15 - File: inc/config.php PHP 7.1.6 (Linux)
Warning [2] Illegal string offset 'password' - Line: 16 - File: inc/config.php PHP 7.1.6 (Linux)
Warning [2] Illegal string offset 'encoding' - Line: 80 - File: inc/config.php PHP 7.1.6 (Linux)

And in bottom page this:

Quote:
MyBB Internal Error

MyBB has experienced an internal error and cannot continue.
Error Type:MyBB Error (42)Error Message:Your board has not yet been upgraded. Please do so before attempting to browse it.
Please contact the MyBB Group for technical support.

Apparently $config was not an array and for my new page was needed to make thaht $config = array();

Now it's working with cookies.

Thanks for all help, much appreciate.

Ahh I gotcha, glad you got it working! Holler if you need more help.
I have one question i want to manually login into a MyBB forum and with my script send a post request using target="_blank" with my bb text.

This works with some forums and some don't. Why? and how to fix it.