× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Authentication from external php page
#1
Hello,
I'm trying to use US on a site that is already complete and currently uses a different password management system (made of php-mysql with standard code). 
But I don't understand how to handle the new situation.

When I have to send the login form data through the classic
<form action="http://www.mysite.com/login.php" method="post"> ......... where should I direct my new request?

If I have to create a new php script what functions can I use to know if the visitor has correctly entered User and Password ?

Are there any guides to manage a site using US without its traditional interface but only by interacting at the php code level?

Thank you for your help!
Maurizio
  Reply
#2
Can you give me an idea of what your current users table looks like? Is it already called users? What is some of the basic info it contains?

Do you know what format the password is stored in? Maybe if you don't you can just post a hashed password and we can figure that out.

UserSpice can definitely do this.
  Reply
#3
Hello Mudmin,
Thank you for your fast reply.

The user table we manage is quite similar to your users table but with fewer fields.

We have : user name, password in MD5, first name, last name, mail, enable/disable, user group and some others fields.

We use a boostrap form to send a PHP script username and password. If the script recognizes the user and if the user is enabled  it redirects to the page from which it is logged in.

Otherwise it does not log in...

I don't understand how to use your login.php to integrate US in our website ( if this procedure is possible with US ).
Thank you
Maurizio
  Reply
#4
My thought would be to rename your table from users to users2 then write a script to foreach through your existing users and put whatever data you have in your users table into ours because you're going to need some of those fields.

Something like...
$migrate = $db->query("SELECT * FROM users2")->results();
foreach($migrate as $m){
$fields = array(
'username'=>$m->username,
'fname'=>$m->fname,
);
$db->insert('users',$fields);
}

In that above example 'username' is the column name in the userspice db, and $m->username the username is the column name in your db, so if yours are different just change it.

Then your login page (should obviously check username and password), but all it has to do is when it finds the user with the matching username and password set $_SESSION['user'] = //the id of the user that logged in

That's it. From there, you're logged in as userspice.
My suggestion would be to put your own login.php form in usersc/login.php this way yours will load instead of ours and the updates won't break it.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)