Login integration for 2 different 3rd party scripts in PHP

Hi, I am trying to create a bridge between two different scripts. One is textpattern for news/blog and another one is a social networking script (SNS). When a user creates an account in textpattern or SNS, I know that it should automatically create a clone account to the other script. But I would like to if a user logs into textpattern, how can I let it login to SNS too? Is there some kind of HTML header command that will do that automatically?

I don't want to create a whole new user session tracking routine for both, because I think that is going to be a huge work from scratch. Thank you.
santockiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mahdii7Commented:
It should be possible to do..

First of all, this was very confusing to me, I am assuming that you have 2 applications:
Social Networking Script
Textpattern CMS

You have both of these scripts combined in one website. You would like to allow a user to log into the website once, however each script requires a separate login by default.

Do each of these scripts require separate registration as well? I would assume so, and if you do not plan to connect the registration process I advise against merging the sign in process as there could easily be complications (different credentials).

If you just wanted to sign in to both accounts at once by a single page, examine the login protocol for each script. Do they require $_REQUEST data? Do they use this data in a function call? Since we are missing the 2 login pages, I will post 2 example login pages and let you fill in the blanks.

If this is the case, simply require() the needed scripts and call the 2 functions on a single page. Hopefully there are no conflicts and it's that simple.
<?php
// SNS Login.php
 
require_once("sns/library/login_functions.php");
 
$username = $_POST['username'];
$password = $_POST['password'];
 
if (doLogin($username, $password)){
  goToHomePage();
}
 
?>
 
<?php
// textpattern Login.php
 
require_once("textpattern/library/functions.php");
 
$uname = $_GET['txtUsername'];
$pword = $_GET['txtPassword'];
 
if (login_user($uname, $pword)){
  header("Location: http://www.somesite.com/members.php");
}
 
?>
 
<?php
// Merged login.php
 
require_once("sns/library/login_functions.php");
require_once("textpattern/library/functions.php");
 
$usrname = $_REQUEST['your_username_field'];
$passwd  = $_REQUEST['your_password_field'];
 
if (login_user($usrname, $passwd) && doLogin($usrname, $passwd)){ 
     header("Location: http://www.yoursite.com/your_landing_page.php");
}else{
   echo "login failed!";
}
 
?>
 
/*
Obviously, this is dependent on the third party applications login protocol. Likely it is NOT that simple. You will have to figure out how they do it, and find a compatible way if running them both at the same time. There's a good chance they either use cookies or sessions to store the validity of the user. Good luck!
*/

Open in new window

0
santockiAuthor Commented:
Thank you for the response. But it is not exactly what I needed. What I need to know is:

 I would like to send HTTP header codes to the second application's login page so it will be logged in, as if the user have inputted the username and the password via <FORM> tag (more like a bot logging in automatically for me, but all this happens in the background, so user will NOT be redirected to the second application). I don't want to use PHP's header() function.  This way, I don't have to include any functions from the second application (either SNS or Textpattern CMS). Is this even possible? Hope it makes sense.

Thank you.
0
santockiAuthor Commented:
Adding to the previous comment...

I have a Contact Form on my site and everyday I get the form message submitted by spam bots automatically. I am trying to make it work similar like that by sending user's username, password and IP info (the IP info means not sending a string, but it should be captured by $_SERVER['REMOTE_ADDR'] variable as if the visitor has physically visited the page for logging in ). Thank you.
0
Mahdii7Commented:
Ah I see, you can use curl for this. I don't have time to go over usage in detail right now, but I'll link you to a reference I've used in the past.

http://www.askapache.com/htaccess/sending-post-form-data-with-php-curl.html

Good luck!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.