Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>How about if you change your username-field to be an unique key -field that means, two rows cannot have same username, which is the case also in primary key fields. This should not break your php-code.</p> <pre><code>CREATE TABLE users ( id int unsigned auto_increment, username varchar(30), password varchar(32), userid varchar(32), userlevel tinyint(1) unsigned not null, email varchar(50), timestamp int(11) unsigned not null, unique key(username), primary key (id) ); </code></pre> <p><strong>Edit:</strong></p> <p>Ok, if you change your database schema you must change also the other code to match the database schema. I.e. in this case you must change the function that inserts user into the database. Let me explain how I debugged this.</p> <p>1) You didin't provide the full source code so I googled for Jpmaster77 and I found <a href="https://github.com/ivannovak/jpmaster77-s-Login-System-" rel="nofollow">this site</a></p> <p>2) I realized you are trying to register into the system and I opened register.php file and I searched the term</p> <blockquote> <p>We're sorry, but an error has occurred</p> </blockquote> <p>and I found the correct line and saw that $_SESSION['regsuccess'] is set but it is set to false. </p> <p>3) Then I opened the process.php file and saw that in the procRegister-function is the line that calls the <code>$session-&gt;register</code> function and it returns 2 in this case because registration is not successful.</p> <p>4) Then I had to know what the <code>$session-&gt;register-function</code> does. I opened <code>session.php</code> file from the include-directory and searched the <code>register</code>-function. I know that this function returns 2 in this case. So I found the <code>return 2;</code> from line 233 that has a comment </p> <blockquote> <p>Registration attempt failed</p> </blockquote> <p>5) If that function returns 2 it must be because <code>$database-&gt;addNewUser</code> function returns false. Again, I opened the <code>database.php</code> file from the include-directory and looked to the <code>addNewUser</code>-function.</p> <p>6) So here this function returns false. And the reason is obvious:</p> <p>The script tries to insert a row into the database without giving column names inside the insert query. So if you change the table column order and add or remove columns, like in this case, that script will fail. Like MySQL's documentation says:</p> <blockquote> <p>If you do not specify a list of column names for INSERT ... VALUES or INSERT ... SELECT, values for every column in the table must be provided by the VALUES list</p> </blockquote> <p>You can try to fix this by giving column names to the insert query, but it is <strong>not recommended</strong> if you don't know what you are doing.</p> <pre><code>$q = sprintf("INSERT INTO ".TBL_USERS." (username, password, userid, userlevel, email, name) VALUES ('%s', '%s', '%s', '%s', '%s', $time, '0', '%s', '0', '0')", mysql_real_escape_string($username), mysql_real_escape_string($password), mysql_real_escape_string($userid), mysql_real_escape_string($ulevel), mysql_real_escape_string($email), mysql_real_escape_string($name)); </code></pre> <p>I hope this post helps you find out problemes and to debug your scripts.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload