I'm working on pset 7, the problem I'm having is that even when i query for username in database, it still tries to register the user and goes to the login screen, heres the code I'm using -

code removed as per course honours policy.

What am I doing wrong please?

2 Answers 2


The problem is a logic error, here:

if ($result === false)

The program should apologize if the result is NOT false. If it is false, that means that the userid doesn't exist in the database, so it is OK to register the new name. If it's true, then the name exists and it should apologize. It's an easy mistake, but easily remedied.

If this answers your question, please click the check mark and accept. Let's keep up on forum maintenance. ;-)

  • Oh I see, for some reason I have it the other way around in my head! Don't code at 2am lol Nov 2, 2015 at 17:18
  • hasn't worked, Its still returning to login even when the user already exists Nov 2, 2015 at 17:37
  • Might be because of how you coded it, or it might be because of other code which you haven't posted. I had to plug your snipet into my code to test it. Also, how did you recode? Did you use '!==' instead of '==='?
    – Cliff B
    Nov 2, 2015 at 18:15
  • I've edited the first post, No i did === true, i'll try the other way, I keep trying differnt ways of coding it. Thanks for your help Cliff Nov 2, 2015 at 18:43
  • boom! !== false fixed it! ha I'm so happy :) Nov 2, 2015 at 18:44

Kris, It looks like you are not actually setting $_SESSION["id"] to anything, so includes/config.php will redirect you back to login.php.

  • Thanks! I'll take a look at that. Nov 2, 2015 at 17:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .