vBulletin - Free Ecards - Debt Consolidation - Web Hosting - Online Advertising

PDA

View Full Version : Register script error


nrodes
Nov 9th 2008, 12:04 pm
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:

Fatal error: Call to undefined function head() in C:\Program Files\Abyss Web Server\htdocs\forum\login\register.php on line 38


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' );
}


?>

Thanks in advance :)

dannywwww
Nov 9th 2008, 12:13 pm
head ( 'location: index.htm' );

should be

header ( 'location: index.htm' );

also why are you md5 hashing the username?

iDemonix
Nov 9th 2008, 12:39 pm
^ 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

nrodes
Nov 9th 2008, 1:51 pm
thanks for the help

kampang
Nov 9th 2008, 2:52 pm
@nrodes

msg error
Fatal error: Call to undefined function head() <--look is that
on line 38 <--here
:D