Jump to content

PHP registration form


Guest Wolominiarz

Recommended Posts

Hi there everyone, I'm attempting to create a registration form in php for my mangos server. I have partially succeeded, I've managed to input the data into my accounts table but I cannot login. I think that there is something wrong with my sha_pass_hash string.

What I do is to let the person registering type in his username, pass and email. The mangos wiki says that the format of the hash is a sha1 encrypted string and looks like "username:password". So what I do in my php script is this:

$hash = sha1($username.":".addslashes($_POST['password']));

however that does not seem to work because i cannot login.

The full code goes like this:

<?php

include '../cfg.php';

$usr = addslashes($_POST['usr']);

$pss = addslashes(sha1($_POST['pss']));

$rep = addslashes(sha1($_POST['rep']));

$mail = addslashes($_POST['mail']);

$exp = addslashes(2);

$err = false;

$hash = sha1($usr.":".addslashes($_POST['pss']));

if(strlen($usr) < 4){

$err = true;

}

if($pss != $rep){

$err = true;

}

if($err == true){

header('Location: reg_fail.php');

}else{

$con = mysql_connect($host,$user,$pass)or die("Could not connect");

mysql_select_db('realmd',$con)or die("Could not select");

mysql_query("INSERT INTO account (username,sha_pass_hash,email,joindate,expansion) VALUES

('$usr','$hash','$mail',NOW(),'$exp')")or die(mysql_error());

mysql_close($con);

header('Location: reg_success.php');

}

?>

Any suggestions?

I could also replace the $hash with SHA1(CONCAT(UPPER('$usr'), ':', UPPER('$_POST['pss']'))), would that make a difference?

Best regards Wolominiarz

EDIT : Problem solved! Thanks anyway :)

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use