PHP Admin Control Panel [modified]
-
I am trying to make a PHP admin control panel, and have it set up, but I have 2 problems. The first one is the control panel is not working. This is the code I am using: The error I get is this: Error: Duplicate entry '0' for key 1 How should I fix this? I have the entry form in the right way, so it's not that, and I know I have the login details right. My second problem is that I can't select the user that I would like to edit. How could I fix that? The table with the usernames and passwords is called users, and I have the login script setup so you don't need to worry about that. Thanks! ;) EDIT!: This script actually creates users, not edits them. How would I fix that?
modified on Sunday, May 31, 2009 5:40 PM
-
I am trying to make a PHP admin control panel, and have it set up, but I have 2 problems. The first one is the control panel is not working. This is the code I am using: The error I get is this: Error: Duplicate entry '0' for key 1 How should I fix this? I have the entry form in the right way, so it's not that, and I know I have the login details right. My second problem is that I can't select the user that I would like to edit. How could I fix that? The table with the usernames and passwords is called users, and I have the login script setup so you don't need to worry about that. Thanks! ;) EDIT!: This script actually creates users, not edits them. How would I fix that?
modified on Sunday, May 31, 2009 5:40 PM
I think the problem is you are trying to create the same row in the table twice. Create an "id" field set to auto_increment as your primary key. Then you can pass it a NULL value. Also, I'm not sure about your post code in the SQL. Try: $password = $_POST['password']; $userlevel = $_POST['userlevel']; $sql="INSERT INTO users (id, password, userlevel) VALUES (NULL, '$password','$userlevel')";
-
I am trying to make a PHP admin control panel, and have it set up, but I have 2 problems. The first one is the control panel is not working. This is the code I am using: The error I get is this: Error: Duplicate entry '0' for key 1 How should I fix this? I have the entry form in the right way, so it's not that, and I know I have the login details right. My second problem is that I can't select the user that I would like to edit. How could I fix that? The table with the usernames and passwords is called users, and I have the login script setup so you don't need to worry about that. Thanks! ;) EDIT!: This script actually creates users, not edits them. How would I fix that?
modified on Sunday, May 31, 2009 5:40 PM
Hi neex1223, With regard to the second problem, you need to use the MySQL set command. Something along the lines of (not syntatically correct) where id = thisId, set password = new password. I emphasise - that's not MySQL code, but it's the right structure.
-
Hi neex1223, With regard to the second problem, you need to use the MySQL set command. Something along the lines of (not syntatically correct) where id = thisId, set password = new password. I emphasise - that's not MySQL code, but it's the right structure.
UPDATE USERS SET USERNAME ='John', PASSWORD='newpass' WHERE ID= '1'