2015-07-03 104 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

相關問題