2012-01-24 55 views
0

我正在使用PHP中的優惠券腳本。在這我必須將我的網址127.0.0.1/couponsite/go/1重定向到www.ebay.com,所發生的事情是127.0.0.1/couponsite/go/1重定向到127.0.0.1/couponsite/go/1/www .ebay.com 其中1與www.ebay.com映射 類似地2與這樣的www.someotherweb.com映射。使用PHP優惠券網站腳本:重定向錯誤php

所以我想知道我的腳本的哪個部分是錯誤?我需要關於這方面的幫助。希望它與.htaccess無關。我有一個文件out.php處理所有重定向。在下面發佈out.php的代碼。

<?php 

    if (intval ($qstring[1]) < 0) 
     exit("No coupon selected."); 

    if ($web == "Website") 
    { 
     $web = $data->select ("Website" , "*" , array ("WebsiteID" => intval ($qstring[1]))) ; 
     $web = $web[0] ; 

     if (! empty ($web)) 
     { 
      $data->update ("Website" , array ("Views" => intval ($web["Views"]) + 1) , array ("WebsiteID" => intval ($web["WebsiteID"]))) ; 
      header ("location:".$web["AffilateURL"]) ; 
      exit(); 
     } 
     else 
     { 
      exit ("Website not found. ") ; 
     } 
    } 
    elseif ($tag == "Tag") 
    { 
     $offer_id = $qstring[1] ; 

     $offer = $data->select ("Tag_Offers" , "*" , array ("Tag_OffersID" => intval ($offer_id))) ; 
     $offer = $offer[0] ; 
     if (! empty ($offer)) 
     { 
      header ("location:".$offer["LandingPage"]) ; 
      exit () ; 
     } 
     else 
     { 
      exit ("Offer not found") ; 
     } 
    } 
    elseif ($tag == "WOffer") 
    { 
     $offer_id = $qstring[1] ; 

     $offer = $data->select ("Website_Offers" , "*" , array ("Website_OffersID" => intval ($offer_id))) ; 
     $offer = $offer[0] ; 
     if (! empty ($offer)) 
     { 
      header ("location:".$offer["LandingPage"]) ; 
      exit () ; 
     } 
     else 
     { 
      exit ("Offer not found") ; 
     } 
    } 
    else 
    { 
     $coupon_id = $qstring[1] ; 

     $coupon = $data->select ("Coupon" , "*" , array ("CouponID" => intval ($qstring[1]))) ; 
     $coupon = $coupon[0] ; 
     if (! empty ($coupon)) 
     { 
      $web = $data->select ("Website" , "*" , array ("WebsiteID" => intval ($coupon["WebsiteID"]))) ; 
      $web = $web[0] ; 

      if (! empty ($web)) 
      { 
       $data->update ("Website" , array ("Views" => intval ($web["Views"]) + 1) , array ("WebsiteID" => intval ($coupon["WebsiteID"]))) ; 
       header ("location:".$web["AffilateURL"]) ; 
       exit(); 
      } 
      else 
      { 
       exit ("Website not found.") ; 
      } 
     } 
     else 
     { 
      exit ("Coupon not found.") ; 
     } 
    } 

?> 

其他信息:我使用WAMP

+0

誰曾經寫過這不是一個很好的PHP開發人員。空()是邪惡的 – dynamic

+0

這將是偉大的,如果你回答這個 – user269751

回答

0

嘗試添加協議( 「HTTP://」)的地址之前。

+0

這樣? header(「location:」「http://.$offer [」LandingPage「]」); 或 header(「location:http://.$offer [」LandingPage「]」); – user269751

+0

它不工作的方式! – user269751

+0

header('Location:http://'。$ offer ['LandingPage']);應該工作。這或者確保$ offer ['LandingPage']具有協議(「http://www.ebay.com/whatever」)。 – Crashspeeder