Jump to content

Recommended Posts

Hey guys.

 

So this is mostly my host's fault but,

 

I got most of a website with a login feature as a cms template.

 

it uses a hash function with sha512.

 

the login feature works great on wampserver(hosting from my windows pc) but when i put it onto my domain, it gives a error when loging in:

 

Fatal error: Call to undefined function: hash() in login.php on line 127

 

 

 

here's the source:

 

   if(isset($_POST['login'])) {
      $u = mysql_real_escape_string(stripslashes($_POST['username']));
      $p = mysql_real_escape_string(stripslashes($_POST['password']));
      $s = mysql_query("SELECT * FROM `accounts` WHERE `name`='".$u."'") or die(mysql_error());
      $i = mysql_fetch_array($s);
      
/*this is line 127*/      if($i['password'] == hash('sha512',$p.$i['salt']) || sha1($p) == $i['password']){
         $userz = mysql_query("SELECT * FROM `accounts` WHERE `name`='".$i['name']."' AND `password`='".$i['password']."'") or die(mysql_error());
         $auser = mysql_fetch_array($userz);
         $_SESSION['id'] = $auser['id'];
         $_SESSION['name'] = $auser['name'];
         $_SESSION['mute'] = $auser['mute'];
         if($auser['webadmin'] == "1"){
            $_SESSION['admin'] = $auser['webadmin'];
         }
         $gmammt = $gmlevel - 1;
         if($auser['gm'] > $gmammt){
            $_SESSION['gm'] = $auser['gm'];
         }
         $name = mysql_query("SELECT * FROM `butsags_profile` WHERE `accountid`='".$auser['id']."'") or die(mysql_error());
         $pname = mysql_fetch_array($name);
         if($pname['name'] == NULL){
            $_SESSION['pname'] = NULL;
         }else{
            $_SESSION['pname'] = $pname['name'];
         }
         $return = "<meta http-equiv=refresh content=\"0; url=?butsags=misc&script=redir\">";
      } else {
         $return = "<p><center>Invalid username or password.</center>";
      }
   }

 

 

Okay so i went to my domain hoster and i asked them whats up and they told me hashing is enabled and to use

echo hash("md5","asdasd");

 

does anyone know how to implement using md5 instead of sha512? i tried swaping them but it still gives me errors.. hmmm

The error message indicates that the PHP has no knowledge of the function hash(), I'd have thought the most likely reason for this would be that you have a version of PHP prior to 5.1.2. Do you know, or can you check what version you have?

 

Putting just this in a file will tell you...

 

<?php
phpinfo();
?>

If you ever get messages like that just look the function up on php.net and it will tell you what versions of PHP it is supported in. Glad we got to the bottom of it though, theres a 'topic solved' button in the bottom left corner you should click . :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.