passwords matching error

Discussion in 'PHP' started by nrodes, Nov 8, 2008.

  1. #1
    I have made a registration page for my login. Whether I enter matching password or not matching passwords it still says they don't match. I can't figure out whats wrong.

    Can anybody else?

    <?php
    
    //get form info
    $firstname=$_POST["firstname"];
    $lastname=$_POST["lastname"];
    $username=$_POST["username"];
    $password=$_POST["password"];
    $confirmppassword=$_POST["confirmpassword"];
    $emailaddress=$_POST["emailaddress"];
    $secretquestion=$_POST["secretquestion"];
    $secretanswer=$_POST["secretanswer"];
    
    //make variables some encrypt
    $cpass = md5($password);
    $cuser = md5($username);
    $csecretanswer = md5($secretanswer);
    $file = "users/" . $user . ".php";
    $data = "<?php $cpass=" . $cpass . "; $cuser=" . $cuser . "; $firstname=" . $firstname . "; $lastname=" . $lastname . "; 
    
    $secretquestion=" . $secretquestion . "; $csecretanswer=" . $csecretanswer . " ?>";
    
    
    //make sure all info is ok
    if ($password!=$confirmpassword)
    	{
    	echo "Your passwords do not match. <a href=\"register2.htm\">Try Again</a><br>"; exit(0);
    	}
    
    if (file_exists($file))
    	{
    	echo "Username is in use. <a href=\"register2.htm\">Try Again</a><br>"; exit(0);
    	}
    
    //make users file
    $handle = fopen($file);
    fwrite($handle, $data);
    fclose($handle);
    
    head ( 'location: index.htm' );
    
    ?>
    PHP:
     
    nrodes, Nov 8, 2008 IP
  2. sandstorm140

    sandstorm140 Peon

    Messages:
    80
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You must md5 encrypt the variable: $confirmppassword
     
    sandstorm140, Nov 8, 2008 IP
  3. dev_SeeInside

    dev_SeeInside Peon

    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    also, you have a typo in the line:

    $confirmppassword=$_POST["confirmpassword"];

    should be

    $confirmpassword=$_POST["confirmpassword"];
     
    dev_SeeInside, Nov 8, 2008 IP
  4. sandstorm140

    sandstorm140 Peon

    Messages:
    80
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    good catch :p
     
    sandstorm140, Nov 8, 2008 IP
  5. nrodes

    nrodes Peon

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    that does not seem to have fixed it
     
    nrodes, Nov 8, 2008 IP
  6. sandstorm140

    sandstorm140 Peon

    Messages:
    80
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Try to echo the password strings to see what the difference between passwords are.
     
    sandstorm140, Nov 9, 2008 IP
  7. nrodes

    nrodes Peon

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    it printed them as matching. But it still says that they don't match. Its very strange.
     
    nrodes, Nov 9, 2008 IP
  8. nrodes

    nrodes Peon

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I found the error. It was just a typo. the only problem is im still getting this

    What exactly does it mean?
     
    nrodes, Nov 9, 2008 IP
  9. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #9
    Your function head() doesn't exist :)

    Check if you include the function the before the use of it .
     
    elias_sorensen, Nov 9, 2008 IP
  10. nrodes

    nrodes Peon

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    ya it does. last line, i just dont know what im suppose to do to it to make it better

     
    nrodes, Nov 9, 2008 IP
  11. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #11
    Ahhh....

    That's not head() you have to use there..

    You're thinking about header :)

    header( 'Location: index.htm' );
    PHP:
     
    elias_sorensen, Nov 9, 2008 IP