好的,所以我正在完成我的网站的最后一步。我想创建一个安装页面,所以如果我在另一个主机/ pma上移动网站,它会自动为我创建管理员帐户和表格(好吧,我不能拼写这个:/)现在它没有显示任何错误,但我无法注册帐户我尝试了我所知道的一切并且它不起作用它总是说用户名已经注册,但它的安装和我删除了一切。我检查了两次删除了两次(或更多),但仍然没有在代码中使用它的错误。这是我将用//行检查的代码,其中检查并显示错误消息。
<?php
if($_POST['registracija'])
{
if($_POST['korisnickoreg'] && $_POST['lozinkareg'] && $_POST['imeprezimereg'])
{
$tabelakorisnici = mysqli_query($konekcija,"CREATE TABLE IF NOT EXISTS `korisnici` (
`Ime` text NOT NULL,
`Lozinka` text NOT NULL,
`ImePrezime` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`Admin` int(11) NOT NULL,
`Sesija` text NOT NULL,
`ID` int(11) NOT NULL,
`PonedelnikCas1` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`PonedelnikCas2` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`PonedelnikCas3` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`PonedelnikCas4` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`PonedelnikCas5` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`PonedelnikCas6` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`PonedelnikCas7` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`VtornikCas1` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`VtornikCas2` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`VtornikCas3` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`VtornikCas4` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`VtornikCas5` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`VtornikCas6` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`VtornikCas7` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`SredaCas1` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`SredaCas2` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`SredaCas3` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`SredaCas4` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`SredaCas5` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`SredaCas6` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`SredaCas7` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`CetvrtokCas1` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`CetvrtokCas2` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`CetvrtokCas3` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`CetvrtokCas4` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`CetvrtokCas5` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`CetvrtokCas6` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`CetvrtokCas7` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`PetokCas1` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`PetokCas2` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`PetokCas3` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`PetokCas4` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`PetokCas5` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`PetokCas6` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`PetokCas7` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`PonedelnikZ` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`VtornikZ` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`SredaZ` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`CetvrtokZ` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`PetokZ` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1");
if($tabelakorisnici == '1')
{
mysqli_query($konekcija, "ALTER TABLE `korisnici` ADD PRIMARY KEY (`ID`)");
mysqli_query($konekcija, "ALTER TABLE `korisnici` MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1");
}
if($tabelakorisnici == '1') echo "TABELA 'korisnici' USPESNO KREIRANA.";
else if($tabelakorisnici != '1') echo "TABELATA 'korisnici' NEMOZE DA SE KREIRA!";
$tabelanovosti = mysqli_query($konekcija, "CREATE TABLE IF NOT EXISTS `novosti` (
`Naslov` text NOT NULL,
`Tekst` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`Vreme` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`Data` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`Od` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`ID` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8");
if($tabelanovosti == '1')
{
mysqli_query($konekcija, "ALTER TABLE `novosti` ADD PRIMARY KEY (`ID`)");
mysqli_query($konekcija, "ALTER TABLE `novosti` MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1");
}
mysqli_query($konekcija, 'SET NAMES utf8');
$korisnicko = mysqli_real_escape_string($konekcija, $_POST['korisnickoreg']);
$lozinka = mysqli_real_escape_string($konekcija, $_POST['lozinkareg']);
$imeiprezime = mysqli_real_escape_string($konekcija, $_POST['imeprezimereg']);
$proverka = mysqli_fetch_array(mysqli_query($konekcija, "SELECT * FROM `korisnici` WHERE `Ime`='$korisnicko'"));
die($proverka);
if($proverka == '0')
{
if(ctype_alnum($korisnicko) && ctype_alnum($lozinka))
{
if(strlen($korisicko) <= 20 && strlen($lozinka) <= 60 && strlen($imeiprezime) <= 60)//da ne se pregolemi :D
{
$sesijaid = hash("sha512", rand() . rand() . rand());
mysqli_query($konekcija, 'SET NAMES utf8');
mysqli_query($konekcija, "INSERT INTO `korisnici` (`Ime`, `Lozinka`, `ImePrezime`, `Admin`, `Sesija`) VALUES ('$korisnicko', '$lozinka', '$imeiprezime', '0', '$sesijaid')");
setcookie("LogiranIme", $korisnicko, time()+60*60*24);//24 saata
setcookie("Sesija", $sesijaid, time()+60*60*24);//24 saata
header('Location: korisnici.php');
}else $greskaregister = 1;
}else $greskaregister = 2;
}else $greskaregister = 3;//this is for giving error message see down there in HTML code I have defined it at the top for global usage and set it to 0
}else $greskaregister = 4;
}
?>
这是发布的HTML代码
<form action = "" method = "post">
<table>
<tr>
<td>
Корисничко име(Латиница / бројки):  
</td>
<td>
<input type="text" name="korisnickoreg" class = "loginboxovi"/>
</td>
</tr>
<tr>
<td>
Лозинка(Латиница / бројки):  
</td>
<td>
<input type="password" name="lozinkareg" class = "loginboxovi"/>
</td>
</tr>
<tr>
<td>
Име Презиме(Кирилица):  
</td>
<td>
<input type="text" name="imeprezimereg" class = "loginboxovi"/>
</td>
</tr>
<tr>
<td>
<input type="submit" name="registracija" value="Регистрирај се" class = "loginboxovikopce"/>
</td>
<td>
<?php
if($greskaregister != 0)
{
if($greskaregister == 1)
{
echo "<font color='red'><b>Не внесовте корисничко име или лозинка!";
}
else if($greskaregister == 2)
{
echo "<font color = 'red'><b>Во корисничко име/лозинка се користат недозволени карактери!";
}
else if($greskaregister == 3)
{
echo "<font color= 'red'><b>Тоа корисничко име веќе постои!";//this is That username already exists
}
else if($greskaregister == 4)
{
echo "<font color= 'red'><b>Немате внесено доволно податоци!";
}
$greskaregister == 0;
}
?>
</td>
</tr>
</table>
</form>