tonnybarros Posted May 5, 2016 Share Posted May 5, 2016 Guys, I need help again. I'm using the API code below to add custom product on my other site. Works already tested. But I must not be allowed the same product be added. I would like to create something that check the product name so that it is not added again? advance thank you for your assistance $url = "https://www.meusite.com.br/includes/api.php"; $postfields["username"] = "user"; # Admin username goes here $postfields["password"] = md5("pass"); # Admin password goes here $postfields["action"] = "addproduct"; $postfields["type"] = "other"; $postfields["gid"] = "18"; $postfields["name"] = $item[item]; $postfields["module"] = "MyModule"; $postfields["paytype"] = "onetime"; $postfields["pricing[1][monthly]"] = $valores; $postfields["description"] = $item[live_preview_url]; $postfields["order"] = "100"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $data = curl_exec($ch); curl_close($ch); 0 Quote Link to comment Share on other sites More sharing options...
tonnybarros Posted May 6, 2016 Author Share Posted May 6, 2016 Friends, if you show me how I can get the names of the products helps, I create the condition. 0 Quote Link to comment Share on other sites More sharing options...
tonnybarros Posted May 6, 2016 Author Share Posted May 6, 2016 I'm trying to create, it seems to work well. Does anyone disagree? require("init.php"); $produto = "Produto Teste"; $sql = "SELECT * FROM tblproducts WHERE name = '$produto'"; $query = mysql_query($sql); $num_rows = mysql_num_rows($query); if($num_rows == 0) { echo "Nao Existe"; } else { echo "Ja existe"; } 0 Quote Link to comment Share on other sites More sharing options...
tonnybarros Posted May 7, 2016 Author Share Posted May 7, 2016 Solved with the code above, who needs that can use the example below. require("init.php"); $produto = "Produto Teste"; $sql = "SELECT * FROM tblproducts WHERE name = '$produto'"; $query = mysql_query($sql); $num_rows = mysql_num_rows($query); if($num_rows == 0) { //The product does not exist, place the api here } else { //Product already exists, do nothing, or put some warning message here } 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.