Tenaciousmug Posted February 6, 2012 Share Posted February 6, 2012 Ok this is my script so far: class User { function generateHash($password, &$saluti=null) { define('SALT_LENGTH', 15); $key = '!@#$%^&*()_+=-{}][;";/?<>.,'; if ($saluti=="") { $saluti = substr(hash('sha512', uniqid(rand(), true).$key.microtime()), 0, SALT_LENGTH); } else { $saluti = substr($saluti, 0, SALT_LENGTH); } return hash('sha512', $saluti . $key . $password); } function validate_user($username,$password) { $mysql = new Database(); $hashedPassword = generateHash($password,''); $ensure_credentials = $mysql->verify_username_and_password($username,$hashedPassword); if($ensure_credentials) { $_SESSION['auth'] == "yes"; header("Location: index.php"); } else return "That was not the correct username or password."; } } It gives me this error: Quote [05-Feb-2012 17:14:59] PHP Fatal error: Call to undefined function generatehash() in /home1/elvonica/public_html/scripts/classes/user.php on line 24 Can anyone help me solve this? Link to comment https://forums.phpfreaks.com/topic/256501-salt-help/ Share on other sites More sharing options...
merylvingien Posted February 6, 2012 Share Posted February 6, 2012 Your function is named: generateHash The error message is saying undefined function generatehash() Notice the capital H Link to comment https://forums.phpfreaks.com/topic/256501-salt-help/#findComment-1314896 Share on other sites More sharing options...
Tenaciousmug Posted February 6, 2012 Author Share Posted February 6, 2012 even if i change it to generate_hash in both places, it still gives me the error message: Quote [05-Feb-2012 19:47:31] PHP Fatal error: Call to undefined function generate_hash() in /home1/elvonica/public_html/scripts/classes/user.php on line 24 The capitalization isn't what's going on. Because in both places I had generateHash. But it just converted it to lowercase. Now I have lowercase, still same error. Anyone? Link to comment https://forums.phpfreaks.com/topic/256501-salt-help/#findComment-1314959 Share on other sites More sharing options...
cooldood Posted February 6, 2012 Share Posted February 6, 2012 It might work putting it into a new file and using the require function to include it in the file, then call the function without it being set as a class? Link to comment https://forums.phpfreaks.com/topic/256501-salt-help/#findComment-1314962 Share on other sites More sharing options...
noXstyle Posted February 6, 2012 Share Posted February 6, 2012 No idea what cooldood just said, but heres your problem: 1. The function is inside User class, therefore you must use $this->generateHash() Btw since the function is same for all instances of the User object you might as well make it static and call it self::generateHash() 2. You cant assign variable reference without variable. Your function definition: function generateHash($password, &$saluti=null) Your call: $this->generateHash($password,'') This will return fatal error. Either remove the variable reference tag (&) or pass a variable to the function. Link to comment https://forums.phpfreaks.com/topic/256501-salt-help/#findComment-1315097 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.