Merging inputs and search results into one input and one result

I have created a unique script that replaces the "ebay link generator"

My PHP script has 3 inputs. Each input does something else:

Three search inputs

First: go to eBay Second: convert the found product (as you saw here ) to another eBay link Last: convert a custom link to another eBay link

I want it to have one Submit button and when the user clicks it gets the information below (it currently displays one information related to finding input).

Like:

One entrance

I think it has to do with javascript, which determines if the user adds "search words" or a URL that starts with " http://ebay.com " and navigates to the correct textarea results.

However, I do not know how to prevent the first login (Search Directly) directly into eBay and give the user a click when they want to go to eBay. Not sure which method to consider here.

Here is the PHP code (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>

      

And here is the second code of the PHP file (gen2.php) I include:

    <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
}
?>

      

I want to do one of three in One search that will display the search results One . The first entry can be avoided and can be used with a button or so. The last two search entries are important.

For example:
User searches for the words "ocz vertex" and gets the result as:

<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>

      

And if he decides to paste the URL http://ebay.com/ , he will get the result as:

<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> 

      

And if he wants to go straight to eBay, he will get a button that will send him to the eBay product page.

Live can be seen here: Three searches and conversions of inputs

+3


source to share


1 answer


With my brother I got it myself:

<?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"];
?>

      



And now it works !

+4


source







All Articles