我有这个代码,但无法让它工作:
$character_set_array = array();
$character_set_array[] = array('count' => 8, 'characters' => '0123456789');
$temp_array = array();
foreach ($character_set_array as $character_set) {
for ($i = 0; $i < $character_set['count']; $i++) {
$temp_array[] = $character_set['characters'][rand(0, strlen($character_set['characters']) - 1)];
}
}
shuffle($temp_array);
$pinstart = 'AA';
$pinend = implode('', $temp_array);
$newpin = $pinstart.$pinend;
function regenerate_pin($pin)
{
if ($PIN == 'PIN') { return ''; } else {
$pin = mysql_real_escape_string($pin); // SECURITY!
$result = mysql_query("SELECT pin FROM pins WHERE pin='$pin' LIMIT 1");
if(mysql_num_rows($result) == 0) {
return 'This pin has already been used';
} else {
$sql = mysql_query("UPDATE pins SET pins='$newpin'");
return "The pin has been regened, the new pin is '.$newpin.'";
} }
}
基本上我试图让它做的是: - 从 HTML 输入框中获取 pin, - 检查 pin 是否存在于数据库中(有效) - 如果存在,将 $pin 替换为 $newpin 并打印出来$newpin,这就是我的桌子的样子
- 关于我的桌子的一些信息:
- 表名 = 针脚 存储针脚的列名为针脚
感谢您的阅读,我希望我能找到一个快速的解决方案。