Register script error

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

  1. #1
    I've been making a a login script and I'm working on the registration page. I'm not that great with php at all and I've just been teaching myself. I'm getting an error that I don't understand. Could somebody help?

    Error:

    Scriopt:
    <?php
    
    //get form info
    $firstname=$_POST["firstname"];
    $lastname=$_POST["lastname"];
    $username=$_POST["username"];
    $password=$_POST["password"];
    $confirmpassword=$_POST["confirmpassword"];
    $emailaddress=$_POST["emailaddress"];
    $secretquestion=$_POST["secretquestion"];
    $secretanswer=$_POST["secretanswer"];
    
    //make variables some encrypt
    $cpass = md5($password);
    $cconfirmpass = md5($confirmpassword);
    $cuser = md5($username);
    $csecretanswer = md5($secretanswer);
    $file = "users/" . $username . ".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="javascript:history.go(-1)">Try Again</A><br>'; exit(0);
    	}
    
    elseif (file_exists($file))
    	{
    	echo 'Username is in use. <A HREF="javascript:history.go(-1)">Try Again</A><br>'; exit(0);
    	}
    
    else
    	{
    	//make users file and redirect
    	$handle = fopen($file, 'w');
    	fwrite($handle, $data);
    	fclose($handle);
    	head ( 'location: index.htm' );
    	}
    
    
    ?>
    PHP:
    Thanks in advance :)
     
    nrodes, Nov 9, 2008 IP
  2. dannywwww

    dannywwww Well-Known Member

    Messages:
    804
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    110
    #2
    head ( 'location: index.htm' );

    should be

    header ( 'location: index.htm' );

    also why are you md5 hashing the username?
     
    dannywwww, Nov 9, 2008 IP
  3. iDemonix

    iDemonix Peon

    Messages:
    37
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ^ What he said, but also you might want to consider strtolower() when hashing things like a secret question, it's annoying when the answer is something like 'Digital point' and you're guessing 'Digital Point', also consider using a salt when making a password hash :)

    Dan
     
    iDemonix, Nov 9, 2008 IP
  4. nrodes

    nrodes Peon

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanks for the help
     
    nrodes, Nov 9, 2008 IP
  5. kampang

    kampang Member

    Messages:
    41
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    @nrodes

    msg error
    Fatal error: Call to undefined function head() <--look is that
    on line 38 <--here
    :D
     
    kampang, Nov 9, 2008 IP