Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

[SOLVED] Registration form inserts a invalid hash :S Please help ASAP

registration

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1 YumadBro

YumadBro

    CC Regular

  • Member
  • PipPipPip
  • 42 posts

Posted 13 December 2012 - 04:19 AM

So whenever i register a user with the sha1 encryption it's generating an invalid hash.
Can anyone see the mistake here? I tried but i couldn't find it.

Code below:


<?php
include("tpl/class.TemplatePower.inc.php");
$tpl = new TemplatePower("html/register.html");
	
$database = new PDO('mysql:host=localhost;dbname=project_2','root','');
$error = NULL;
$tpl->prepare();
if (isset($_POST['submit'])) {
//variable een waarde geven
$username  = $_POST['username'];
$password  = $_POST['password'];
$password2  = $_POST['password2'];
$email = $_POST['email'];
$email2 = $_POST['email2'];
$voornaam = $_POST['voornaam'];
$achternaam = $_POST['achternaam'];
  //als naam niet is in gevuld fout melding!
if(empty($username))
{
$error = 'Geen gebruikersnaam ingevuld';
}

else if(empty($password))
{
$error = 'Geen wachtwoord ingevuld';
}
else if(empty($password2))
{
$error = 'Geen wachtwoord ingevuld';
}
else if(empty($email))
{
$error = 'Geen email ingevuld';
}

else if(empty($email2))
{
$error = 'Geen email ingevuld';
}

else if(empty($voornaam))
{
$error = 'Geen voornaam ingevuld';
}

else if(empty($achternaam))
{
$error = 'Geen achternaam ingevuld';
}

else if($password != $password2)
{
$error = 'De wachtwoorden komen niet overeen';
}
else if($password2 != $password)
{
$error = 'De wachtwoorden komen niet overeen';
}
else if($email != $email2)
{
$error = 'Emails komen niet overeen';
}
else if($email2 != $email)
{
$error = 'Emails komen niet overeen';
}

else
{
$hashpassword = sha1($password);
$sql = "INSERT INTO leden (username, password, email, voornaam, achternaam) VALUES (:username, :password, :email, :voornaam, :achternaam)";
//prepare voor de database
$db = $database->prepare($sql);
//hier voert hij het uit
$db->execute(array(
':username' => $username,
':password' => $hashpassword,
':email' => $email,
':voornaam' => $voornaam,
':achternaam' => $achternaam
));
echo 'U heeft zich geregistreerd!';
}
}
if (isset($error))
{
$tpl->newBlock("ERROR");
$tpl->Assign("ERROR" , $error);
}
$tpl->printToScreen();
?>


#2 YumadBro

YumadBro

    CC Regular

  • Member
  • PipPipPip
  • 42 posts

Posted 13 December 2012 - 05:41 AM

Solved it. The string legth was too short.

#3 Roger

Roger

    Skadoosh!

  • Administrator
  • 1222 posts

Posted 13 December 2012 - 10:17 AM

This topic has been marked as SOLVED. If you have a similar question or topic, you can go back to the subforum and start a new topic to continue discussions.

New around here? Click here to register and start participating in under a minute?

Or do a quick search and you may find the answer you're looking for.





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download