为什么我不能使用header()重定向到页面?

时间:2015-07-03 17:11:40

标签: php html

问题是该网址应该重定向到Activated.php,但它会显示http://localhost/SP/activation.php/Activated.php而不是http://localhost/SP/Activated.php

<?php
require 'db.php';
$msg='';

if(!empty($_GET['code']) && isset($_GET['code']))
{
  $code=mysqli_real_escape_string($connection, $_GET['code']);
  $c=mysqli_query($connection, "SELECT pawnshop_id FROM pawnshop WHERE activation='".$code."'");

  if(mysqli_num_rows($c) > 0)
  {
    $count = mysqli_query($connection, "SELECT pawnshop_id FROM pawnshop  WHERE activation='".$code."' AND business_status='0'");
    if(mysqli_num_rows($count) == 1)
    {
        mysqli_query($connection, "UPDATE pawnshop SET business_status='1' WHERE activation='".$code."'");

        //This the code where it should redirect
        header("Location: Activated.php");
    }
    else
    {
        $msg="Your account is already active, no need to activate again";
    }
  }
  else
  {
    $msg="Wrong activation code";
  }  
  mysqli_close($connection);
}

?>
<?php echo $msg; ?>

1 个答案:

答案 0 :(得分:1)

header("Location: /SP/Activated.php");