这是一个与 PHP 相关的问题。
我已经广泛搜索了以下问题的解决方案,但没有找到适合我的解决方案。如果有人可以帮助我,将不胜感激。
我的想法是创建一个登录页面,如果将“特定”预定注册号提供/发送给用户,则访问登录页面并且文件中存在该号码,以执行 /允许登录权限。
例如,如果一个用户的注册号是12345,而另一个是123,想先搜索一下用户的号码是否存在,然后执行something()。
因此,如果“123”已经存在,则搜索“12345”与搜索“234”不同,因此它必须找到一个或多个特定数字。
如果有所不同,则在数字之前和/或之后会有一个“空格”。
这将在现有文件中。
代码:
<?php
$filename = 'datafile.txt';
// Data file may contain the following number(s) or any other
// 123 (no)
// 1234 (match)
// 12345 (no)
// 123456 (no)
// exact match needed to proceed to page fopen($filename);
$searchfor = '1234';
// this needs to be a variable
// I don't know what the number will be used.
$file = file_get_contents($filename);
if (preg_match($file, $searchfor)) {
echo "Match found. Proceed to the page.";
} else {
echo "Match not found. Try again.";
}
fclose($filename);
?>
谢谢你。任何帮助表示赞赏,欢呼。
弗雷德