Login and Registration Using OOP with MySQLi
71 comments to “Login and Registration Using OOP with MySQLi”
  1. @bonaca: actually this is an easiest login & registration method. this is only for the beginners who wants to start with oop php so that’s why i just didn’t pack the email varification at this code sorry for that!!

  2. I am really inspired together with your writing abilities as neatly as with the format in your weblog. Is that this a paid topic or did you modify it yourself? Anyway keep up the excellent quality writing, it is uncommon to see a nice weblog like this one nowadays..

    • nothing stays paid in the world of web sir… & this is not a paid topic also !! what i tries to do here give the knowledge that i got coz sharing extends more knowledge & i believe that truely !! thanks for the nice comment !! 🙂

  3. how can i remove this warning:
    Warning: Cannot modify header information – headers already sent by (output started at C:\xampp\htdocs\w3progm_oop_login\include\class.user.php:70) in C:\xampp\htdocs\w3progm_oop_login\login.php on line 11
    plz say. i am new in php.

  4. Somebody essentially help to make critically articles I might state. That is the first time I frequented your website page and thus far? I amazed with the research you made to create this actual put up extraordinary. Wonderful activity!

  5. this is the part i don’t get it , can u explain it to me ?
    first we deal with query verify yes yes bla bla and :
    $user_data = mysql_fetch_array($result);
    $count_row = mysql_num_rows($result);

    if ($count_row == 1) {
    $_SESSION[‘login’] = true;
    $_SESSION[‘uid’] = $user_data[‘uid’];

    • yes ofcourse i can explain. while fetching data of the user i’m counting if there’s any other user in that name is stored in my db or not. if yes means 1 row is there in that name than it’ll store that login user name in a session variable & if not than it’ll create an error message, that’s it !!

  6. hai..your post oops concept is nice for me..if u dont mind can u please give me ur gmail id??i want talk 2 u on something else??

    • you can’t do that. without submitting form how can you insert something. is there any logic? what you can do is may be can do with jquery on hover or click effect by which you can run an ajax request than by that request you can insert something into db. otherwise it’s not possible. there must be a click or hover or some event needs to take place. try study jquery with ajax request. may be it can help you.

    • what you need to do is just insert some data using php into mysqli.
      when inserting some data for registration use this code for the query

      $query = "INSERT INTO users SET uname='Stuttgart', upass='****', fullname='Stuttgart Yeah', uemail'test@test.com',)";
      printf ("New Record has id %d.\n", $mysqli->insert_id);

      this code will help you to insert your desired data..

  7. pleas i want the code of the payment method in the technical support system for college and how can I set the terms of reference of each user if a student or admin , or what is known as URL .. thanks in advance 🙂

    • For setting the terms of reference of each user you might need to user user role in your system by that you can have the information of each user who’s logging into your system with the credibility. In that way you can provide the terms to each person of that role. And for the payment method what sort of payment method you want to use? Is it paypal or something else? For that you might want to google that or if you’re not able to do this than might want to hire someone who can do this job for you. 🙂

  8. For me it’s getting error while login on the line as (Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\xampp\htdocs\oop_log_tuts\include\class.user.php on line 35)

    and also getting error on the line 19 as (trying to get property of non-object),i can’t rectify the error ,help me please

    • I think there’s an object error. According to your first error there seems to be syntax error. Please debug with print_r or var_dump the whole array of objects. Then you might be able to sought out the errors.
      As for the second error you’re pulling a non-object file. Please do this in the correct manner. Debug the array of objects. You’ll get the idea of what you’re pulling from the database. May be you’re pulling something like this:

      $arr = array(

      with this type of code $arr->a; You should get such arrays with this manner $arr[‘a’]. I think this is the solution. Debug first then you’ll get the answer.

    • “true” & “false” is the boolean part. If you get true it means the user entered the corrent information into the database & if you get false that means the user entered the wrong information.

  9. Result on local server:
    Notice: Trying to get property of non-object in C:\xampp\htdocs\Niet goed\include\class.user.php on line 28
    0Data cannot inserted

  10. First time. I am going to share view with you Mr Code provider.

    Really Your code is good for fresher developer of php.

    Nice Dear.

    R K Singh : 9818597149 New delhi (INDIA).
    Good Luck.

  11. Great blog you have here but I was curious about if you knew of any message boards that cover the same topics talked about
    in this article? I’d really like to be a part of group where I can get comments from other
    knowledgeable individuals that share the same interest.

    If you have any recommendations, please let me know.

  12. Warning: myswli_fetch_array() expects parameter 1 Tobe mysqli_result,Boolean given in line no 43.
    Notice:trying to get property of non object in class.user.php on line 44.
    When I login the above errors are occured please help me on that…

  13. HEy, I am getting this warning

    Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\wamp64\www\sub\log.php on line 23
    But, I checked my code my I followed all tings, which you mentioned in your post.
    Any help will be highly appreciated.

  14. 2018 still this code is kicking! 🙂
    this was what I was looking for… how to call a login from a class! thanks a lot, buddy!

  15. Salamo Alikom first I really appropriate your effort and your contribution ,thanks for everything .
    second I have a notice that the query :
    “SELECT uid from users WHERE uemail=’$emailusername’ or uname=’$emailusername’ and upass=’$password'”;

    can any one enter email with wrong password will login
    must to:
    “SELECT uid from users WHERE uemail=’$useremail’ and upass=’$password’ or uname=’$useremail’ and upass=’$password'”;

    and again thank you very much

  16. Very shortly this site will be famous among all blogging and site-building visitors, due to it’s pleasant posts

  17. Hello sir,
    As i have learned a lot from this tutorial, But i am stuck in case of edit user. I have a view page where all user are shown and I can easily edit ,delete every user. But when I edit single user then how to apply already user register validation check in case of edit. In case of add user, it work fine but in case of edit user, i am stuck. For example, As in a database table, if some entries like xyz@gmail.com already exist. When i go to view page and edit single user whose email id is like pqr@gmail.com, But when he enter xyz@gmail, alert has been shown. Any help would be appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *