Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Question in mysql and php

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #28643
    ahmed
    Member

    hi
    im new to php and my sql
    i have a login system and i made a database with mysql conting 4 feilds and one of theme is called database wich every user will control one other database when he login i made a qury for that how can i make a qury to now for wich database he controls i have four databases every one will have it own user and an admin user how can make a mysql qury to now how is the user database and if he the admin it will redirect him for an admin page?

    #74199
    Democritus
    Member

    I literally don’t understand what you’re saying. Punctuation, grammar, and spelling are essential for communication.

    From what I could surmise, you’re trying to decide if a user is of a specific type, and taking action accordingly. On your database table "users", have a field called "type". Make it a Boolean if there is only 2 types of users, or a Varchar if there are many. Then, your **QUERY** can look something like this:

    "SELECT type FROM users WHERE user_name=’$name’ AND password=’$pass’"

    In your php, simply do this:

    if ($type==(0 or admin, depending on the type of field)) {
    //Do whatever for admins
    }
    else {
    //Do whatever for regular users
    }

    In the future, please group your questions into single thoughts separated by punctuation for clarity. It makes it WAY easier for people to help you.

    -D

    #74949
    ahmed
    Member

    thanx for the reply
    it helped me verymuch

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.