我的数据库中有一个表ver_code
,表内只有一行调用code
,并且我插入了一些验证码,例如 ABCDEF , GHIJKL 现在我的以下代码无法使用下面的简单表格验证我的表中的代码
<?php
if (isset($_POST['ver_code']))
{
$ver_code = $_POST['ver_code'];
if(!empty($ver_code)){
try{
$conn = new PDO("mysql:host=localhost;dbname=pro1", "pro1", "4931//4931");
}
catch(PDOException $pe)
{
die('Connection error, because: ' .$pe->getMessage());
}
$sql = "SELECT `code` FROM `ver_code`";
$stmt = $conn->query($sql);
if(!$stmt)
{
die("Execute query error, because: ". $conn->errorInfo());
}
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$row = $stmt->fetch();
if($row['code'] == $ver_code['code']){
echo "Account Verified ! ";
}else{
echo "Invalid Verification Code !";
}
}else{
echo "Plz enter a verification code ... ";
}
}
?>
<form action="index2.php" method="POST" >
<input type="text" name="ver_code" />
<input type="submit" value="Verify" />
</form>