2017-07-07 84 views
3

我犯了一个独特的脚本,取代“易趣链接生成”合并搜索输入和结果到一个输入和一个结果

我的PHP脚本有3个输入。每一个输入点别的东西:

Three Search Inputs

第一:转发到易趣 二:转换产品搜索(因为您看到here)到另一个易趣链接 最后:转换自定义链接插入到另一个易趣链接

我希望它有一个“提交”按钮,当用户点击时,他会得到下面的3个信息(目前它显示一个有关搜索输入的信息)。

就像是:

One input

我认为这是关系到JavaScript的检测,如果以“http://ebay.com”开始,用户将“搜索词”或URL转发到正确的textarea的结果。

但是,我不知道如何防止第一个(直接搜索)输入直接进入eBay,并让用户选择点击时他想要转发到eBay。不知道在这里考虑什么方法。

这里的PHP(的index.php)代码:

<head> 

    <!-- start direct ebay search script--> 
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> 
<script type="text/javascript"> 
$(function() { 
    $("#tfq2b").click(function() { 
     if ($("#tfq2b").val() == "Search ebay Now"){ 
      $("#tfq2b").val(""); 
     } 
    }); 
}); 
</script> 
</head> 

    <div style="width:800px; padding-left:300px;"> 

    <!-- start direct ebay search--> 
    <br><br><br><h2>Search Directly</h2> 
    <div> 
     <form method="get" action="http://rover.ebay.com/rover/1/711-53200-19255-0/1"> 

       <input type="text" id="tfq2b" class="tftextinput2" name="icep_uq" size="21" maxlength="120" value=""> 
       <input type='hidden' name='icep_ff3' value='9'> 
       <input type='hidden' name='pub' value='5575165347'> 
       <input type='hidden' name='toolid' value='10001'> 
       <input type='hidden' name='campid' value='5337851510'> 
       <input type='hidden' name='icep_sortBy' value='12'> 
       <input type='hidden' name='icep_vectorid' value='229466'> 
       <input type='hidden' name='kwid' value='902099'> 
       <input type='hidden' name='mtid' value='824'> 
       <input type='hidden' name='kw' value='lg'> 

<input type="submit" value="search" class="btne"> 
     </form> 
    </div> 
    <!-- end direct ebay search--> 


<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> 
<h2>Share ebay link</h2><br> 
<input type=text style="font-size: 13px; font-family: tahoma,arial; font-weight: bold; color: #000000; BORDER: #555 1px solid ; BACKGROUND-COLOR: #FFF" input name="url" size="20"> 

<input type="SUBMIT" name="submit" VALUE="Submit"> 
</form> 

<?php include 'gen2.php'; ?> 
</div> 

<?php 
if(isset($_POST['submit'])){ 
$url = $_POST['url']; 
$name=array($url); 
foreach ($name as $name) 

if (strlen($url) > 100) { 
echo "<br><center><font color=\"red\">The field cannot contain more than 150 characters.</center>"; 

Die(); 
} 
} 
?> 
<br> 
<center> 
<form name="vini"> 
<a class="highlighttext" href="javascript:HighlightAll('vini.select1')">Select All</a><br> 
<textarea id="p1" name="select1" rows=4 cols=100 style="font-family:tahoma;color:#555;border:1px dashed #ccc"> 
http://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=10&pub=5575165347&toolid=10001&campid=5337851510&customid=&icep_uq=<?php echo $url ?>&icep_sellerId=&icep_ex_kw=&icep_sortBy=15&icep_catId=&icep_minPrice=&icep_maxPrice=&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg 
</textarea> 
</form> 

<?php 
} 
?> 
</body> 
</html> 

这里是第二个PHP文件(gen2.php)的代码,我有:

<h2>Custom Link</h2> 

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> 

    <input type=text style="font-size: 13px; font-family: tahoma,arial; font-weight: bold; color: #000000; BORDER: #555 1px solid ; BACKGROUND-COLOR: #FFF" input name="url2" size="20"> 

    <input type="SUBMIT" name="submit2" VALUE="Submit"> 
    </form> 

    <?php 
    if(isset($_POST['submit2'])){ 
    $url2 = $_POST['url2']; 
    $name=array($url2); 
    foreach ($name as $name) 

    if (strlen($url2) > 100) { 
    echo "<br><center><font color=\"red\">The field cannot contain more than 150 characters.</center>"; 

    Die(); 
    }} 
    ?> 
    <br> 
    <center> 

    <form name="vini"> 
    <a class="highlighttext" href="javascript:HighlightAll('vini.select1')">Select All</a><br> 

    <h2>Share ebay Custom link:</h2> 
    <textarea id="p2" name="select1" rows=3 cols=100 style="font-family:tahoma;color:#555;border:1px dashed #ccc"> 
    http://rover.ebay.com/rover/1/711-53200-19255-0/1?ff3=4&pub=5575165347&toolid=10001&campid=5337851510&customid=&mpre=<?php echo $url2 ?>  
    </textarea> 

<br> 
</form> 

<?php 
} 
?> 

我想拍一部所有三入一号将显示的搜索输入一号搜索结果。第一个输入可以避免,并可以使用一个按钮左右。最后两个搜索输入很重要。

例如:
用户搜索词“OCZ的顶点”,并得到结果为:

<textarea id="p1" name="select1" rows=4 cols=100 style="font-family:tahoma;color:#555;border:1px dashed #ccc"> 
http://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=10&pub=5575165347&toolid=10001&campid=5337851510&customid=&icep_uq=<?php echo $url ?>&icep_sellerId=&icep_ex_kw=&icep_sortBy=15&icep_catId=&icep_minPrice=&icep_maxPrice=&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg 
</textarea> 

而且,如果他决定要插入“http://ebay.com/”的网址,他将得到的结果为:

<textarea id="p2" name="select1" rows=3 cols=100 style="font-family:tahoma;color:#555;border:1px dashed #ccc"> 
http://rover.ebay.com/rover/1/711-53200-19255-0/1?ff3=4&pub=5575165347&toolid=10001&campid=5337851510&customid=&mpre=<?php echo $url2 ?>  
</textarea> 

如果他想直接去eBay,他会得到一个按钮,将他转发到eBay产品页面。

直播可以看这里:Three Search and Convert Inputs

+2

请点击''''并添加足够的代码来创建[mcve] – mplungjan

回答

4

与我的兄弟我知道了自己:

<?php 

if(isset($_POST['submit'])) { 
    $url = $_POST['url']; 
    $name = array($url); 
    foreach ($name as $name) { 
     if (strlen($url) > 100) { 
      echo "<br><center><font color='red'>The field cannot contain more than 150 characters.</center>"; 

      Die(); 
     } 

    } 
} 
$token = "token"; 


if (count(explode('ebay.com',$url))>1) { 
    $ebay_url = "http://rover.ebay.com/rover/1/711-53200-19255-0/1?ff3=4&pub=5575165347&toolid=10001&campid=5337851510&customid=&mpre=".urlencode($url).""; 
} 
else{ 
    $ebay_url = "http://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=10&pub=5575165347&toolid=10001&campid=5337851510&customid=&icep_uq=".urlencode($url)."&icep_sellerId=&icep_ex_kw=&icep_sortBy=15&icep_catId=&icep_minPrice=&icep_maxPrice=&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg"; 
} 

$endpoint = "https://api-ssl.bitly.com/v3/shorten?access_token=".$token."&longUrl=".urlencode($ebay_url); 
$json = json_decode(file_get_contents($endpoint), true); 
echo $ebay_link = $json["data"]["url"]; 
?> 

现在这是工作

相关问题