butsags Posted October 17, 2009 Share Posted October 17, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/178035-solved-hash-function-doesnt-wanna-play-fair/ Share on other sites More sharing options...
cags Posted October 17, 2009 Share Posted October 17, 2009 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(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/178035-solved-hash-function-doesnt-wanna-play-fair/#findComment-938741 Share on other sites More sharing options...
butsags Posted October 18, 2009 Author Share Posted October 18, 2009 yes i do. i have 4.4.9 okay so its the fact of my php version. thanks so much. all i have 2 do is update my php then. good thatll be easy Quote Link to comment https://forums.phpfreaks.com/topic/178035-solved-hash-function-doesnt-wanna-play-fair/#findComment-939115 Share on other sites More sharing options...
cags Posted October 18, 2009 Share Posted October 18, 2009 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 . Quote Link to comment https://forums.phpfreaks.com/topic/178035-solved-hash-function-doesnt-wanna-play-fair/#findComment-939124 Share on other sites More sharing options...
butsags Posted October 18, 2009 Author Share Posted October 18, 2009 thanks so much Quote Link to comment https://forums.phpfreaks.com/topic/178035-solved-hash-function-doesnt-wanna-play-fair/#findComment-939186 Share on other sites More sharing options...
salathe Posted October 18, 2009 Share Posted October 18, 2009 If you didn't want to, or couldn't, upgrade PHP then the sha1 and md5 functions should be available in your version of PHP. Quote Link to comment https://forums.phpfreaks.com/topic/178035-solved-hash-function-doesnt-wanna-play-fair/#findComment-939250 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.