slpctrl Posted April 28, 2008 Share Posted April 28, 2008 I can't figure out why this isn't outputting my data correctly. (using the mhash module) <?php Function MD4($input) { $MD4Hash=bin2hex(mhash(MHASH_MD4,$Input)); } echo <<<THIS <form name="hasher" method="post" action=""> Text to Hash: <input type="text" name="mhash"><p/> <input type="submit" name="Submit" value="Submit"> </form><p /> THIS; if (isset($_POST['mhash'])) { $info=md4($input); echo($info); } else die(); ?> Link to comment https://forums.phpfreaks.com/topic/103204-solved-string-troubles/ Share on other sites More sharing options...
pocobueno1388 Posted April 28, 2008 Share Posted April 28, 2008 How is it outputting the data? Your function doesn't return anything, so try this: <?php function MD4($input) { return $MD4Hash=bin2hex(mhash(MHASH_MD4,$Input)); } ?> Link to comment https://forums.phpfreaks.com/topic/103204-solved-string-troubles/#findComment-528629 Share on other sites More sharing options...
slpctrl Posted April 28, 2008 Author Share Posted April 28, 2008 How is it outputting the data? Your function doesn't return anything, so try this: <?php function MD4($input) { return $MD4Hash=bin2hex(mhash(MHASH_MD4,$Input)); } ?> still doesn't work =( Link to comment https://forums.phpfreaks.com/topic/103204-solved-string-troubles/#findComment-528631 Share on other sites More sharing options...
slpctrl Posted April 28, 2008 Author Share Posted April 28, 2008 One obvious problem I found is: <?php Function MD4($input) { $MD4Hash=bin2hex(mhash(MHASH_MD4,$Input)); return $input; } echo <<<THIS <form name="hasher" method="post" action=""> Text to Hash: <input type="text" name="mhash"><p/> <input type="submit" name="Submit" value="Submit"> </form><p /> THIS; if (isset($_POST['mhash'])) { md4($_POST['mhash']); } else die(); ?> The correct variable to md4 is $_POST['mhash']; and not $input (I used that variable but changed it). So, here's where I'm at and no luck. Link to comment https://forums.phpfreaks.com/topic/103204-solved-string-troubles/#findComment-528636 Share on other sites More sharing options...
DarkWater Posted April 28, 2008 Share Posted April 28, 2008 <?php Function MD4(&$input) { $input=bin2hex(mhash(MHASH_MD4,$Input)); } echo <<<THIS <form name="hasher" method="post" action=""> Text to Hash: <input type="text" name="mhash"><p/> <input type="submit" name="Submit" value="Submit"> </form><p /> THIS; if (isset($_POST['mhash'])) { md4($_POST['mhash']); echo $_POST['mhash']; } else die(); ?> Do you want it to return it, or do you want it to actually change the value of what you pass to it? Since you aren't storing it in a variable in the example script, I'll assume you want it to actually change $_POST['mhash']. Try that code. Link to comment https://forums.phpfreaks.com/topic/103204-solved-string-troubles/#findComment-528644 Share on other sites More sharing options...
slpctrl Posted April 28, 2008 Author Share Posted April 28, 2008 <?php Function MD4(&$input) { $input=bin2hex(mhash(MHASH_MD4,$Input)); } echo <<<THIS <form name="hasher" method="post" action=""> Text to Hash: <input type="text" name="mhash"><p/> <input type="submit" name="Submit" value="Submit"> </form><p /> THIS; if (isset($_POST['mhash'])) { md4($_POST['mhash']); echo $_POST['mhash']; } else die(); ?> Do you want it to return it, or do you want it to actually change the value of what you pass to it? Since you aren't storing it in a variable in the example script, I'll assume you want it to actually change $_POST['mhash']. Try that code. I got it kinda...it's doing the same thing as my code currently: <?php Function MD4($input) { return $MD4Hash=bin2hex(mhash(MHASH_MD4,$Input)); } echo <<<THIS <form name="hasher" method="post" action=""> Text to Hash: <input type="text" name="mhash"><p/> <input type="submit" name="Submit" value="Submit"> </form><p /> THIS; if (isset($_POST['mhash'])) { $newhash = md4($_POST['mhash']); echo $newhash; } else die(); ?> It returns the same hash for every string I input :\ Link to comment https://forums.phpfreaks.com/topic/103204-solved-string-troubles/#findComment-528647 Share on other sites More sharing options...
slpctrl Posted April 28, 2008 Author Share Posted April 28, 2008 If anyone is interested here is working code: <?php Function MD4(&$input) { $input=bin2hex(mhash(MHASH_MD4,$input)); } echo <<<THIS <form name="hasher" method="post" action=""> Text to Hash: <input type="text" name="mhash"><p/> <input type="submit" name="Submit" value="Submit"> </form><p /> THIS; if (isset($_POST['mhash'])) { md4($_POST['mhash']); echo $_POST['mhash']; } else die(); ?> It was the cap in $Input in the MD4 function that threw it off Link to comment https://forums.phpfreaks.com/topic/103204-solved-string-troubles/#findComment-528663 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.