Jump to content

PHP Login/Register Multiple Tables


CBResources

Recommended Posts

Hi there, I've just registered here and had a quick look around but couldn't find the answer I was looking for so I hope I'm posting this question in the right place.

 

I want to write a PHP Login/Registration script that I can run on a website I am developing for a client but this website has more than one piece of software on it (each with it's own user-tables) and this is the first time I have had to integrate software before so I need a bit of help.

 

When a user fills in the registration form, that data needs to be sent to the relevent user-tables for each application running on the website & when a user logs in, they need to be authenticated for each of the applications also so that we can have a one-click login process.

 

I hop

Link to comment
Share on other sites

That would be great if I knew how to do that lol.

 

This is why I came here. To get some info on how I could achieve this.

 

Basicall when somebody registers for the site, I want them to be able to register for ALL of the services on the site in one-form so they won't have to re-register to use the forums, then re-register again to buy from the shop etc... Then I want them to be able to login to each service just by logging in ONCE on the main site.

 

If table integration is the answer, then super... just tell me how to do it :)

 

 

Link to comment
Share on other sites

Doing this for any particular existing application is not a trivial task.

 

Your first step would be to examine the code and database tables for all your applications and learn exactly what method and data is being used to register a visitor and what method and data is being used to log visitors in and keep them logged in (and any related tasks like displaying visitors on line, log out...)

 

Then you would be able to plan the cleanest universal solution that requires the minimum of modification to the code of the applications.

Link to comment
Share on other sites

Honestly if you are very new to this sort of thing I would more so recommend simply creating a work-around for this process, your own registration script can simply add multiple user records (one for each service's user table -- mind you the WordPress login you may want to be careful with considering giving everyone access to your CMS may not be a good thing), then create a user table for your own login purposes that simply reference the appropriate records from each of the other user tables. This way when you login, you identify the user based on one user table by pulling the appropriate records associated with the current login from the other user tables.

 

The only tricky portion of this process would be in the actual login process, this is where you would need to identify the appropriate function that processes a login request on behalf of those services, or you can attempt to simply do more of an HTTP request on the login scripts already supplied for each of the services. Either method would take a little bit of research, but its far less than making an attempt to alter the code altogether to work differently than it was originally intended. This isn't a process I would recommend for someone who doesn't have the experience. Your bound to end up with a million-and-one headaches throughout the process, and most likely will cause breaks in the original scripts your using since making one change will most likely affect other areas of the system, and so on and so forth throughout the entire services script.

 

Hopefully I'm not being too direct with this one, but it would be my suggestion. Did notice that someone is offering assistance to help you alter the scripts in an effort to integrate, but I still don't recommend obtaining his/her help (simply because what will happen when that nice individual is no longer there and you are faced with the need to make changes to your own scripts, which inadvertently require further changes inside of the pre-mades? it wont be pretty).

 

Good luck, if you want my further advice on such a research process I'm more than willing to offer any further advice. Just let me know.

Link to comment
Share on other sites

Thanks very much for your reply. You seem to understand it a lot more than I do and to be honest with you, without wanting to sound disrespectful, most of what you said went right over my head lol. So I don't think I will attempt to integrate. I would really much rather workaround it like you said.

 

So where do I start? How do I get the "Registration" script to copy the user's details in to each user-table used by the individual applications? They are all on the same database.

 

Once I've got the Registration side of it working... I can move on to logging people in. Let's take this one step at a time lol. I'm not usually one to get involved in this line of coding but I'm trying to help out a friend developing this site with as little cost as possible and people are wanting to charge hundreds of pounds which we simply don't have in the budget so I need to try and do this myself.

 

 

Link to comment
Share on other sites

  • 2 years later...
if(isset($_POST['submit'])){
        $uname = $_POST['uname'];
        $pass = $_POST['pass'];
        $cnvrt_pass = md5($pass); 
        
 
        //$table = "s_admin";
//        $condition = "`a_uname`='".$uname."' and `a_pass`='".$pass."'"; 
//        $fetchuser = $school->fetchrecord($table,$condition);
//        if(0<count($fetchuser)){
//            $_SESSION['valid_user'] = $uname;
//            header("location:index.php");
//            }else{
//            $error = "User name or passsword invalid!";
//            }                 
//     }
 
 
        $table = "s_admin";
        $condition = "`a_uname`='".$uname."' and `a_pass`='".$pass."'"; 
        $fetchuser = $school->fetchrecord($table,$condition);
        if(0<count($fetchuser)){
            $_SESSION['valid_user'] = $uname;
            header("location:admin/view_schools.php");
        }else {
            $error = "User name or passsword invalid!";
            }
            if(isset($error)){
                $table = "s_user";
        $condition = "`u_uname`='".$uname."' and `u_pass`='".$pass."' and `u_status`= '1'"; 
        $fetchuser = $school->fetchrecord($table,$condition);
        if(0<count($fetchuser)){
            $_SESSION['valid_user'] = $uname;
            header("location:local_user/u_dashboard.php");
        }else {
            $error = "User name or passsword invalid!";
            }
        }
            
     }

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.