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 Quote Link to comment 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>'; } ?> Quote Link to comment 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. Quote Link to comment 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> Quote Link to comment 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.