<?php
session_start();
session_register(\"username2\");
$username2 = \"$username\";
$password2 = \"$userpass\";
$file = \"file.txt\";
$userPattern = \"(\[)($username2)(\])\";
$passwordPattern = \"(PASSWORD=)($password2)\";
// Fetch file into an array
if(!($text = @file( $file, \"r\" ))) {
echo \"ERROR OPENING FILE\";
} //End if
else {
for ($i = 0; $i < count($text); $i++) {
if (ereg($userPattern, $text[$i], $match)) {
for ($j = 0; $j < 16; $j++) {
if (ereg($passwordPattern, $text[$i + $j], $match)) {
echo \"<META HTTP-EQUIV=\\"refresh\\" content=\\"1;
URL=www.someurl.com\\">\";
} //End if
} //End for
} //End if
} //End for
} //End Else
?>
Thanks everyone for help so far, Now I have another qustion, what if the stuff in the text file did not have a certain amount of line in it.
For example..
[usernmae]
level=
password=
email=
[username2]
level=
priv=
email=
connect=
[username3]
level=
Users enter thier name and pass through a html form, then the script checks that username and pass against the file and if they match allows them to continue, if not sends them back someplace else. So far this script can do it if, all entries have the same amount of lines, is there a way to do it with varying lines? I know it can be done in asp, what about php?
thanks for your time