Problem in my php file for creating new member-user!

Discussion in 'PHP' started by lounar, Nov 10, 2007.

  1. #1
    ok guys i have attached my php file for creating a new user-member
    everytime i try to make a new one i get an error telling me that the password already exists even if its not! so any ideas?

    if u want any help about the file or there is sthing u dont understand plz let me know!
     

    Attached Files:

    lounar, Nov 10, 2007 IP
  2. bobb1589

    bobb1589 Peon

    Messages:
    289
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you should take that part out... its stupid to check it the password already exists... the password doesnt HAVE to be unique from every other user... the password is linked to the username so the two have to match up...
     
    bobb1589, Nov 10, 2007 IP
  3. lounar

    lounar Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i have took it off but ptroblem still exists!
     
    lounar, Nov 10, 2007 IP
  4. Brewster

    Brewster Active Member

    Messages:
    489
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    60
    #4
    bobb1589 is correct - dont check to see if just the password exists. Also the following logic is incorrect:

    else if ($password = $row['pass'])
    PHP:
    The single equals sign assigns the value in $row['pass'] to the variable $password. You need to use two equals signs to compare.

    Brew
     
    Brewster, Nov 10, 2007 IP
  5. lounar

    lounar Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    ok done! but now creates the member but not giving him status!
    every new one record takes status 0...

    any ideas about that?
     
    lounar, Nov 10, 2007 IP
  6. Brewster

    Brewster Active Member

    Messages:
    489
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    60
    #6
    This code:

    $access = $_POST['status'];
    PHP:
    should be this:

    $access = $_POST['Status'];
    PHP:
    Note the captial 'S'.

    Brew
     
    Brewster, Nov 10, 2007 IP
  7. lounar

    lounar Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    changed and still not working i had mention it before i post ://
     
    lounar, Nov 10, 2007 IP
  8. Brewster

    Brewster Active Member

    Messages:
    489
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    60
    #8
    Had another look and $access is not used anywhere in the script

    Brew
     
    Brewster, Nov 10, 2007 IP
  9. lounar

    lounar Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    ok it finally takes the status but now i cant login with the new one!

    here is my login php code
     
    lounar, Nov 10, 2007 IP
  10. lounar

    lounar Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    brewster have u checked that? ;)
     
    lounar, Nov 10, 2007 IP
  11. Brewster

    Brewster Active Member

    Messages:
    489
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    60
    #11
    Try echoing the query and checking the result by entering it into phpmyadmin

    Brew
     
    Brewster, Nov 10, 2007 IP
  12. lounar

    lounar Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    i checked phpmyadmin and it has been created a new 1 record with the following:


    memID name status
    11 anima 1

    i think the problem has to do with:

    f (mysql_num_rows($result) == 1){

    $row = mysql_fetch_array($result);

    $_SESSION['username'] = $username;

    $_SESSION['memID'] = $row['memID'];

    $_SESSION['login'] = true;



    if($row['status'] == 1){

    $_SESSION['status'] = 1;

    }

    elseif($row['status'] == 2){

    $_SESSION['status'] = 2;

    }

    elseif($row['status'] == 3){

    $_SESSION['status'] = 3;
    }

    elseif($row['status'] == 4){

    $_SESSION['status'] = 4;
    }


    else{

    $_SESSION['status'] = false;

    }



    the rows here.I am new in php so i dont know how to do what u told me!
     
    lounar, Nov 10, 2007 IP
  13. Brewster

    Brewster Active Member

    Messages:
    489
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    60
    #13
    ok, try echoing the values that are returned from the sql query and compare them to what you think they should be.

    Brew
     
    Brewster, Nov 10, 2007 IP
  14. lounar

    lounar Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    gimme an example for the current prob cause i didnt understand u again ://
     
    lounar, Nov 10, 2007 IP
  15. Brewster

    Brewster Active Member

    Messages:
    489
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    60
    #15
    ok. Use the code below


    f (mysql_num_rows($result) == 1){
    
    $row = mysql_fetch_array($result);
    
    $_SESSION['username'] = $username;
    
    $_SESSION['memID'] = $row['memID'];
    
    $_SESSION['login'] = true;
    
    // add the line below to print out what is retreived from the query
    print_r( $row );
    
    if($row['status'] == 1){
    
    $_SESSION['status'] = 1;
    
    }
    
    elseif($row['status'] == 2){
    
    $_SESSION['status'] = 2;
    
    }
    
    elseif($row['status'] == 3){
    
    $_SESSION['status'] = 3;
    }
    
    elseif($row['status'] == 4){
    
    $_SESSION['status'] = 4;
    }
    
    
    else{
    
    $_SESSION['status'] = false;
    
    }
    PHP:
    Brew
     
    Brewster, Nov 10, 2007 IP
  16. lounar

    lounar Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    ok i did that but i dont know what to check after that...explain me in steps plz ;)
     
    lounar, Nov 10, 2007 IP
  17. Brewster

    Brewster Active Member

    Messages:
    489
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    60
    #17
    post the result that the code gave. If you didnt see anything different, then that code was not executed.

    Brew
     
    Brewster, Nov 10, 2007 IP
  18. lounar

    lounar Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #18
    where i can execute that code man?

    sorry for being so noob...
     
    lounar, Nov 10, 2007 IP
  19. lounar

    lounar Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    ok man all my problems are solved now
    everything works just perfect

    hope to find u here any time i have prob
     
    lounar, Nov 10, 2007 IP