royal27 Posted August 16, 2013 Share Posted August 16, 2013 Hi can anyone tell me if is a module for protect products with password? I tried something but i cant get it work,if someone knows how to do it please let me know Here it is {if ($_POST["codurideaccess"] == '$product->getProductName($codurideaccess.id_product)')} {else} <form action="{$link->getPageLink}" method="post"> <input type="text" name="codurideaccess"> <input type="submit" name="Submit" value="GET ACCESS" class="exclusive" /> </form> {/if} Link to comment Share on other sites More sharing options...
bellini13 Posted August 16, 2013 Share Posted August 16, 2013 I would change your if statement to this. Remove the quotes and use $smarty instead of _POST {if ($smarty.post.codurideaccess == $product->getProductName($codurideaccess.id_product))} Also, I'm not sure what $codurideaccess.id_product is supposed to be? You are comparing it against the product name, but what is it? You should also clarify what doesn't 'work'? Is the post failing? Are you getting a blank page? Are you not seeing your form? 1 Link to comment Share on other sites More sharing options...
royal27 Posted August 16, 2013 Author Share Posted August 16, 2013 (edited) $codurideaccess is made by me in dbase table ps_product I would change your if statement to this. Remove the quotes and use $smarty instead of _POST {if ($smarty.post.codurideaccess == $product->getProductName($codurideaccess.id_product))} Also, I'm not sure what $codurideaccess.id_product is supposed to be? You are comparing it against the product name, but what is it? You should also clarify what doesn't 'work'? Is the post failing? Are you getting a blank page? Are you not seeing your form? Edited August 16, 2013 by royal27 (see edit history) Link to comment Share on other sites More sharing options...
royal27 Posted August 16, 2013 Author Share Posted August 16, 2013 i am not getting anything,it's shows me this form,but is not working because when i am writing the code shows me the same form <form action="{$link->getPageLink}" method="post"> <input type="text" name="codurideaccess"> <input type="submit" name="Submit" value="GET ACCESS" class="exclusive" /> </form> Link to comment Share on other sites More sharing options...
bellini13 Posted August 16, 2013 Share Posted August 16, 2013 can you provide the actual HTML output of the form when the page is loaded? I would also revise you code to include some debug statements so you can see what the id_product is {if ($_POST["codurideaccess"] == '$product->getProductName($codurideaccess.id_product)')} {else} <p>The codurideaccess product id is: {$codurideaccess.id_product}</p> <p>The product id is: {$id_product}</p> <form action="{$link->getPageLink}" method="post"> <input type="text" name="codurideaccess"> <input type="submit" name="Submit" value="GET ACCESS" class="exclusive" /> </form> {/if} Link to comment Share on other sites More sharing options...
royal27 Posted August 17, 2013 Author Share Posted August 17, 2013 (edited) I've uploaded here the html output,and product.tpl same homefeatured.tpl and i've made a new row in table ps_product named codurideaccess with varchar 255,as defined http://fastupload.ro...8ce5b43be0.html Edited August 17, 2013 by royal27 (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted August 17, 2013 Share Posted August 17, 2013 Ok, to begin with your form action is not being set so you should correct that <form action="" method="post"> <input type="text" name="codurideaccess"> <input type="submit" name="Submit" value="GET ACCESS" class="exclusive" /> </form> In your product.tpl, you are executing php sql query. You should avoid doing this. This type of coding belongs in a module or Product controller override. <?php $codurideaccess=mysql_fetch_array(mysql_query("SELECT codurideaccess FROM marked_cards_factory_product WHERE id_product='".$product.id_product."'")); ?> And finally I had suggested to add some debug statements to the product.tpl so that you can confirm what these values actually are. Link to comment Share on other sites More sharing options...
royal27 Posted August 17, 2013 Author Share Posted August 17, 2013 ok i will come back with a replie,thank you Link to comment Share on other sites More sharing options...
royal27 Posted August 17, 2013 Author Share Posted August 17, 2013 Ok,i put the code in controllers/productcontroller.php and still dosent work $codurideaccess=mysql_fetch_array(mysql_query("SELECT codurideaccess FROM marked_cards_factory_product WHERE id_product='".$product.id_product."'")); i tried with this code in product.tpl and still dont work,i am not familiar with prestashop.....and i dont know where to put it and where must finish the code.... {if($smarty.post.codurideaccess == $product->getProductName($codurideaccess.id_product))} Link to comment Share on other sites More sharing options...
bellini13 Posted August 17, 2013 Share Posted August 17, 2013 In productcontroller, did you add the $codurideaccess variable to the smarty array? If not, then go back and do that. And a third time, have you added any debug statements to the product.tpl to confirm what the values are? For example... <p>The codurideaccess product id is: {$codurideaccess.id_product}</p> <p>The product id is: {$id_product}</p> Link to comment Share on other sites More sharing options...
royal27 Posted August 17, 2013 Author Share Posted August 17, 2013 no,because i am not familiar with smarty,i must read about smarty and after do some change.... Link to comment Share on other sites More sharing options...
bellini13 Posted August 17, 2013 Share Posted August 17, 2013 just search for smarty in productcontroller and you will see that an array of name/value pairs are registered with the smarty engine. This is how information (data) is transferred from the controller to the view in an MVC pattern. (model view controller). In your case the model is the sql query you are executing. The controller is the productcontroller, and the view is product.tpl So now that you have the information you need in the $codurideaccess array. You need to make that information available to the view, by adding the information to smarty. Try and come back if you have questions. Link to comment Share on other sites More sharing options...
royal27 Posted August 17, 2013 Author Share Posted August 17, 2013 ok,thank you for support Link to comment Share on other sites More sharing options...
nathanrobjohn Posted September 10, 2013 Share Posted September 10, 2013 did you get this working? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now