2015-07-03 129 views
1

问题是URL应重定向到Activated.php,但它显示http://localhost/SP/activation.php/Activated.php而不是http://localhost/SP/Activated.php为什么我不能使用header()重定向到页面?

<?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; ?> 
+0

尝试添加'的error_reporting(E_ALL);函数ini_set( 'dispaly_errors',1);?'在刚刚php'后'<你的页面的顶部,并检查到底是什么错误发生? –

+0

添加斜线/标题(“位置:/Activated.php”); – bader

+2

从手册中,'HTTP/1.1需要绝对URI作为»Location的参数:包括scheme,hostname和绝对路径,但有些客户端接受相对URI。你通常可以使用$ _SERVER ['HTTP_HOST'],$ _SERVER ['PHP_SELF']和dirname()来从你自己的亲戚中创建绝对URI。 http://php.net/manual/en/function.header.php – chris85

回答

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

谢谢bro!我非常赞赏它。 – soyan

相关问题