javascript - php mail form on magento product page -


i trying make simple price match contact form on product page in magento. have separate php file doesn't seem receive commands view.phtml file.

this form code located inside /app/design/frontend/default/my_design/template/catalog/product/view.phtml

<div class="pricematcher">                     <body class="body">                         <div id="pricematch" style="display:none;">                         <!-- popup div starts here -->                             <div id="popupcontact">                             <!-- contact form -->                             <form action="send_contact.php" id="form" method="post" name="form">                             <img id="close" src="<?php echo $this->getskinurl(); ?>images/close.png" onclick="div_hide()"</img>                             <h2 class="h2price">price match</h2>                             <hr id="hrprice">                             <input id="name" name="name" placeholder="name" type="text">                             <input id="email" name="email" placeholder="email" type="text">                             <input id="productname" name="productname" placeholder="<?php echo $_helper->productattribute($_product, $_product->getname(), 'name') ?><?php echo $this->__(' part #: ');?><?php echo $_helper->productattribute($_product, nl2br($_product->getsku()), 'sku') ?>" type="text" readonly>                             <input id="competitor" name="competitor" placeholder="competitor product link" type="text">                             <textarea id="msg" name="msg" placeholder="message"></textarea>                             <a href="javascript:%20check_empty()" id="submit">submit</a>                             </form>                             </div>                             <!-- popup div ends here -->                         </div>                             <!-- display popup button -->                      </body>                 </div>                  <img id="popup" src="<?php echo $this->getskinurl(); ?>images/price-match.png" onclick="div_show()"</img> 

this javascript makes form pop , display

// validating empty field function check_empty() { if (document.getelementbyid('name').value == "" ||      document.getelementbyid('email').value == "" ||     document.getelementbyid('msg').value == "") { alert("fill fields !"); } else { document.getelementbyid('form').submit(); alert("thank submitting price match inquiry"); } } //function hide price match function div_hide(){ document.getelementbyid('pricematch').style.display = "none"; } //function display price match function div_show() { document.getelementbyid('pricematch').style.display = "block"; } 

this php file form action should send send_contact.php file located in same directory view.phtml

<?php $subject = "price match"; $message = $_post['msg']; $name = $_post['name']; $product = $_post['productname']; $competitor = $_post['competitor']; $mail_from = $_post['email'];  // enter email adress $to = "myemail@email.com"; $body = "$message, $competitor, $product"; $send_contact = mail($to,$subject,$body, "from: " . $mail_from);  //check if message sent if ($send_contact){    echo "we recieved"; } else { echo "error"; } ?> 

every thing works when make in seperate folder on server , execute outside of magento.

you should put send_contact.php @ magento's root directory.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -