17 thoughts on “Insert, View, Edit and Delete Record from Database Using PHP and MySQL

  1. Pingback: Simple User Registration & Login Script in PHP and MySQL | HTML CSS PHP Tutorials

  2. Pingback: Allow Only Logged in Users to View Files | HTML CSS PHP Tutorials

  3. Hi Javed,

    Thank you so much. I was struggling to get this type of code (particularly) for the past 5 years and today i found it. I need small help here. Here you are trying to insert, edit and update in the webform. I will insert a record by uploading from back end or using macro in excel. now what i want is : the moment user logs in with their credential i want the data to be visible for edit and update (which was assigned against them). The data has the names of the users. (it is just audit allocation). When updated they should be able to use a drop down of correct and incorrect. Thats it. Thank you so much for your help. Murugan

    Like

    • Hi Murugan,

      I’m glad that you found it helpful and yes this is based on web using php, if you want to desktop application then you should try any other desktop language, PHP is mainly for online application, if you are using Excel then you should use something like Dot NET.

      Like

      • Hi Javed,
        Thanks for response. I am looking at Web application only. In fact I’ve developed one Web application in my team with xammp where 40 people use to access this across Chennai and Bangalore for inserting a record but sadly I failed to create a code for editing and updating and now when I put your code it is working but drawback is all the records are visible for editing and updating. I want only the records that were updated by the respective users. Thanks Murugan

        Like

      • This is simple, all you need is to create two different tables of admin and users, also create two login in 1 for admin and another for user, admin login will redirect to the admin dashboard where he can insert, edit and update, while users can only view record. Hope this help you.

        Like

      • Hi Javed,
        So speed in your response. 🙂 I think you did not understand my requirement. Let me tell you in this way. We both are using the site and you have updated 10 record and I have updated 10 record. Now when I want to edit and update I should be able to edit only my records and not your records. Thanks Murugan

        Like

      • You just need to add 1 column in your table with name something like InsertedBy and insert logged in user userid at the time of record insertion, and on the page where you are placing edit link, check if InsertedBy == logged in user so display edit link simple 🙂

        Like

  4. Hi Javed,

    Thanks..i got it :-). I have not inserted column.(just to make it simple). below is the code
    $sel_query=”Select * from new_record WHERE submittedby='”.$_SESSION[“username”].”‘ ORDER BY id desc;”;

    Like

    • Thanks Paola, but edit file already contain auth.php file in the top, yes delete.php does not contain, although only login user can see delete link but yes you are right it is better to use auth.php in delete file also.

      Like

  5. Javed
    HI, just dl, open and review this “edit” php. Very simple and clean! Thank you for sharing. I wish your best future success, for your published work is helping many.
    Alex

    Like

Leave a comment