I made a unique script that replaces "ebay link generator"
My PHP script has 3 inputs. Every input does something else:
The first: Forward into ebay The second: Convert product searched (as you saw here) into another ebay link The last: Convert Custom link inserted, into another ebay link
I want it to have one "Submit" button and when user clicks he get the 3 information below (currently it display one information related the input searched).
Like that:
I think it is related to javascript that detect if user insert "search words" or URL that starts with "http://ebay.com" and forward to the correct textarea results.
However, i do not know how to prevent the first (Search Directly) input from getting directly into ebay, and to give the user option to click when he wants to forward into ebay. Not sure what method to consider here.
Here the PHP (index.php) code:
<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 PHP file (gen2.php) code 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 make one all the three into One search input that will display One Search Results. The first input can avoid and can used by a button or so. The last two search inputs are important.
For example:
User search 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 decide to insert "http://ebay.com/" URL, 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 want to go straight to ebay he will get a button that will forward him to ebay product page.
Live one can see here: Three Search and Convert Inputs
1 Answers
Answers 1
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 is working!
0 comments:
Post a Comment