有人能向我解释一下我在哪里做错了请,如果我使用error_reporting其显示没有错误,但没有发生在我的数据库
<?php
//error_reporting(E_ERROR | E_PARSE);
include ("db.php");
$codec=$_POST['code'];
if(isset($_POST['code']) && !empty($_POST['code']))
{
$search = mysql_query("SELECT code,active FROM users WHERE code='".$codec."' AND active='0'") or die(mysql_error());
$match = mysql_num_rows($search);
if($match > 0)
{
mysql_query("UPDATE users SET active='1' WHERE code='".$codec."' AND active='0'") or die(mysql_error());
echo '<div class="statusmsg">Your account has been activated, you can now login</div>';
}
else
{
// No match -> invalid url or account has already been activated.
echo '<div class="statusmsg">The url is either invalid or you already have activated your account.</div>';
}
}
?>
你在这里遇到这个问题…
if(!isset($_POST['code']) && !empty($_POST['code']))
if(isset($_POST['code']) && !empty($_POST['code']))
在下面输入12345
实际上会返回12345
,因此您可以以此为基础。
<?php
$codec=$_POST['code'];
if(isset($_POST['submit'])){
if(isset($_POST['code']) && !empty($_POST['code']))
{
echo "Code :" .$codec;
}
}
?>
<form action="" method="post">
Code:
<input type="text" name="code">
<br>
<input type="submit" name="submit" value="Submit">
</form>