cirma Posted July 3, 2007 Share Posted July 3, 2007 Hi, I'm trying to make a form where a surfer can enter a list of words in a text box, then the script spits out the words and their corresponding md5 value in a table. But I end up with it just doing the first letter of the first word they entered. Here's my code: <?php $data=''; if (isset($_POST['data']) && strlen($_POST['data'])>0) { $data=$_POST['data']; } if (isset($_POST['submit'])) { if (strlen($data)>0) { $newarr = explode("\n\r", $data); print '<b>Results</b><br><br>'; print '<table width = "800" columns = "2" border = "2">'; foreach($newarr as $line) { print '<tr>'; print '<td>'; print $newarr{$line}; print '</td>'; print '<td>'; print md5($newarr{$line}); print '</td>'; print '</tr>'; } print '</table><br><br>'; } else print '<b>You need to enter some data</b><br><br>'; } ?> <b>Enter data here</b><br><br> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <textarea name="data" rows="15" cols="100"> <?php echo $data; ?> </textarea> <input type="submit" value="Submit" name="submit"> </form> I've tried diff combinations of \n\r but I think what's happening is I'm not getting to the next line? Any ideas? thanks Link to comment https://forums.phpfreaks.com/topic/58150-md5-hash-issue/ Share on other sites More sharing options...
trq Posted July 3, 2007 Share Posted July 3, 2007 <?php foreach($newarr as $line) { print '<tr>'; print '<td>'; print $line; print '</td>'; print '<td>'; print md5($line); print '</td>'; print '</tr>'; } ?> Link to comment https://forums.phpfreaks.com/topic/58150-md5-hash-issue/#findComment-288420 Share on other sites More sharing options...
cirma Posted July 3, 2007 Author Share Posted July 3, 2007 Thanks thorpe...but that gives me the md5 for everything they put in the box. I want to md5 each individual line in the box. ??? edit: so they enter like: word1 blah meh and then the script spits out word1 fkgjdfkgjf98454b blah rRmfgTlfm459839t meh j453fjvBEmtltjk etc. Link to comment https://forums.phpfreaks.com/topic/58150-md5-hash-issue/#findComment-288424 Share on other sites More sharing options...
clanstyles Posted July 3, 2007 Share Posted July 3, 2007 Try this. I would do it this way. <?php $data=''; if (isset($_POST['data']) && strlen($_POST['data'])>0) { $data=$_POST['data']; } if (isset($_POST['submit'])) { if (strlen($data)>0) { $newarr = explode("\r", trim($data)); print '<b>Results</b><br><br>'; print '<table width = "800" columns = "2" border = "2">'; for($i=0;$i<count($newarr);$i++) { print '<tr>'; print '<td>'; print $newarr[$i]; print '</td>'; print '<td>'; print md5($newarr[$i]); print '</td>'; print '</tr>'; } print '</table><br><br>'; } else print '<b>You need to enter some data</b><br><br>'; } ?> <b>Enter data here</b><br><br> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <textarea name="data" rows="15" cols="100"> </textarea> <input type="submit" value="Submit" name="submit"> </form> Link to comment https://forums.phpfreaks.com/topic/58150-md5-hash-issue/#findComment-288484 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.