PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
if the user you are trying to log in is on line two, the script will die since it doesnt match line 1.. if the user logging in is on line 1 (and there is a line 2), the user will be "verified", but then the script goes on and tries to verify him with line 2 and dies..
<?php
$userstring = $_POST['user'].'::'.$_POST['pass'].'::'.$_SERVER['HTTP_PORT'];
$valid_user = file('my_secret_file');
if (!in_array($userstring,$valid_user)) die ('Simon says your not worthy');
?>
ereg uses the POSIX regex engine which uses a lot of resources and is very slow, if you need the power of regex, use preg.. but any such simple replacement like that doesnt reed regex, there is plenty of other string functions that can do such things, e.g. str_replace
the foreach loop goes thru every record in the array, and $idx becomes the array index and $vu the string, then it re-assigns a trim()'ed version (which takes away whitespace on either end) to the same position in the array.