点击该按钮后更改

时间:2016-08-08 07:49:09

标签: php mysql

请帮助我使这段代码完美无缺

<?php
    if(isset($_POST['btn-verif'])){ 
      $q1 = "UPDATE `user2` SET `activecode` = `1` WHERE `user2`.`email` = '$baseACC';";
      $result = mysql_query($q1);
      if(mysql_query($q1)==TRUE){
              echo "UPDATE SUCCES";
        }else {
            echo "UPDATE FAIL";
        }
        }echo "Wrong Code";
        ?>

我希望如果我按下按钮(btn-verif)执行SQL查询并根据activecode10更新为email = '$baseACC';,如果是代码就像我想要的那样(TRUE)他将执行此代码echo "UPDATE SUCCES";

这是我的HTML代码

<p>Dear <?php echo $userRowX['namalengkap']; ?></p> 
<p>You need to <strong>verified</strong> your account by click this link</p> 
<a href="verified.php" target="_blank"><button class="btn btn-primary" name="btn-verif">Verify Your Account Now</button></a>
  

抱歉我的英文不好;)

2 个答案:

答案 0 :(得分:1)

使用form tag

在表单中使用post method
<p>Dear <?php echo $userRowX['namalengkap']; ?></p> <p>You need to <strong>verified</strong> your account by click this link</p> 

<form method= "Post">
<a href="verified.php" target="_blank"><button class="btn btn-primary" name="btn-verif">Verify Your Account Now</button></a>
</form>

答案 1 :(得分:0)

这只是一种方法。但我会建议使用@ user1234

  <?php
  if(isset($_GET['verify'])){ 
  $q1 = "UPDATE `user2` SET `activecode` = `1` WHERE `user2`.`email` = '$baseACC';";
  $result = mysql_query($q1);
  if(mysql_query($q1)==TRUE){
          echo "UPDATE SUCCES";
    }else {
        echo "UPDATE FAIL";
    }
    }
    else{
     echo "Wrong Code";
    }
    ?>
   <p>Dear <?php echo $userRowX['namalengkap']; ?></p>
   <p>You need to <strong>verified</strong> your account by click this link</p>
   <a href="verified.php?verify=1" target="_blank"><button class="btn btn-primary" name="btn-verif">Verify Your Account Now</button></a>