I have a flatfile database file with the following numbers:
1
2
3
4
5
etc.
The numbers correspond to a USER ID where a person would enter any of those numbers above, in order to login.
I do not want to modify my file. My question is, if there's a way to add an accepted "PREFIX".
For example, a user logs in with:
abcd1
abcd2
abcd3
abcd4
abcd5
etc.
But my data file is still, but does not contain the prefix "abcd":
1
2
3
4
5
etc.
It would also have to be a "perfect" match. The tests I have done so far have not been conclusive
I guess using an accepted "array" would be the way to go?
My present login PHP script is this, but only works on an exact match for a number, I would like to add a prefix that I can change later on:
<?php
date_default_timezone_set('America/New_York');
$today = mktime(0, 0, 0, date("m"), date("d"), date("y"));
$currenttime = date('h:i:s:u');
list($hrs,$mins,$secs,$msecs) = split(':',$currenttime);
echo "<center><form action=\"" . $PHP_SELF . "\" method='post'><input onkeypress=\"return isNumberKey(event)\" type='text' name='uNum' /><input type='submit' value='Submit' /></form></center>";
if(!$_POST['uNum']) {
die('<center>Entrer votre numéro d\'inscription pour finaliser votre demande.</center>');
}
$numbers = file_get_contents("datafile.txt");
$uNumber = $_POST['uNum'];
if ( @preg_match( "/([^0-9]{$uNumber}[^0-9])/", $numbers ) ) {
print_r( "<center>The number $uNumber is good. You may proceed.</b><br><br>" );
file_put_contents($_POST['uNum'].".txt",$_POST['uNum'] . "\nUsed on ".date("m/d/Y", $today). (" $hrs:$mins:$secs")."");
include 'validate_process.php';
if (isset($_POST['uNumber']))
{
$uNumber = $_GET['inscripnum1'];
}
} else {
echo "<center>Sorry, this login number does not exist.</center>";
}
?>