Jump to content

Send form filled by customer to my email


vinhhoa1

Recommended Posts

I am trying to create a form and then have customers filled them out. Once they they click the submit button, the page should send the email with all the inputs from customers to my email. I was able to get the page to send the email, but not the inputs from  customers. Please take a look at my code and let me know what wrong with it. English is not my mother tongue; please excuse any errors on my part. Thank you

display.tpl


<h2>{l s='All products' mod='testmodule'}</h2>


Customer Name
<input class="customerName" id="cName" name="cName"></input>
Billing Address
<input class="BillingAddress" id="billingA" name="billingA"></input>


<form action="" method="post" id="carform">
 <p>Select a product:</p>
<select name="carlist" form="carform">
  <option value="volvo"> {$values}</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>
 <input type="submit" name="submit" value = "submit" />
</form>


<div id="contact_block" class="block">
	<h4 class="title_block">{l s='Contact us' mod='mymodule'}</h4>
	<div class="block_content clearfix">
			<p>{l s='Our support hotline is available 24/7.' mod='mymodule'}</p>
			{if $telnumber != ''}<p class="tel"><span class="label">{l s='Phone:' mod='mymodule'}</span><span itemprop="telephone"><a href="tel:{$telnumber|escape:'html':'UTF-8'}">{$telnumber|escape:'html':'UTF-8'}</a></span></p>{/if}
			{if $email != ''}<a href="mailto:{$email|escape:'html':'UTF-8'}" title="{l s='Contact our expert support team!' mod='mymodule'}">{l s='Contact our expert support team!' mod='mymodule'}</a>{/if}
	</div>
</div>
<script type="text/javascript">
var cName = "{$cName}";
</script>

display.php

<?php
class mymoduledisplayModuleFrontController extends ModuleFrontController
{


  public function initContent()
  {
  	$cName = Configuration::get('cName');
  	$billingA = Tools::getValue('billingA');
  	$this->display_column_left = false; // hides left column
    parent::initContent();
    $this->setTemplate('display.tpl');

		$sql = new DbQuery();
$sql = 'SELECT * FROM '._DB_PREFIX_.'mymodule1
    WHERE id_product = 1';

if ($row = Db::getInstance()->getRow($sql))
$values = $row['option'];

           

	$this->context->smarty-> assign('values', $values);

		if (Tools::isSubmit('submit')){

			///////////Mail
		 Mail::Send((int)(Configuration::get('PS_LANG_DEFAULT')), // defaut language id
        'contact', // email template file to be use
        $this->displayName.' Subject', // email subject
        array(
          '{email}' => Configuration::get('PS_SHOP_EMAIL'), // sender email address
          '{message}' => $this->displayName.' has been installed on:'._PS_BASE_URL_.__PS_BASE_URI__ ,// email content,
          '{cName}' => Tools::safeOutput($cName),
      	  '{billingA}' => Tools::safeOutput($billingA),
        ), 
        '#########@yahoo.com', // receiver email address 
        NULL, NULL, NULL);

		header( 'Location: http://localhost/index.php?fc=module&module=mymodule&controller=display' ) ;
		}
  
	}

}

    <table class="table table-mail" style="width:100%;margin-top:10px;"><tbody><tr><td class="space" style="width:20px;padding:7px 0;"> </td>
<td align="center" style="padding:7px 0;">
<table class="table" bgcolor="#ffffff" style="width:100%;"><tbody><tr><td align="center" class="logo" style="border-bottom:4px solid #333333;padding:7px 0;"><a title="{shop_name}" href="{shop_url}" style="color:#337ff1;"> <img src="{shop_logo}" alt="{shop_name}" /></a></td>
</tr><tr><td align="center" class="titleblock" style="padding:7px 0;"><span style="color:#555454;font-family:'Open-sans', sans-serif;font-size:small;"> <span class="title" style="font-weight:500;font-size:28px;text-transform:uppercase;line-height:33px;">Message from a {shop_name} customer</span> </span></td>
</tr><tr><td class="space_footer" style="padding:0;"> </td>
</tr><tr><td class="box" style="border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0;">
<table class="table" style="width:100%;"><tbody><tr><td width="10" style="padding:7px 0;"> </td>
<td style="padding:7px 0;"><span style="color:#555454;font-family:'Open-sans', sans-serif;font-size:small;"> <span style="color:#777;"> <span style="color:#333;"><strong>Customer e-mail address: <a href="mailto:{email}" style="color:#337ff1;">{email}</a></strong></span><br /><br /><span style="color:#333;"><strong>Customer message:</strong></span> {message}<br /><br /><span style="color:#333;"><strong>Customer Name:</strong></span> {FIRSTNAME} {LASTNAME}<br />
<br /><br /><span style="color:#333;"><strong>Customer Name:</strong></span> {cName}<br />
<br /><br /><span style="color:#333;"><strong>Billing Address: </strong></span> {billingA}<br />

<span style="color:#333;"><strong>Attached file:</strong></span> {attached_file} </span> </span></td>
<td width="10" style="padding:7px 0;"> </td>
</tr></tbody></table></td>
</tr><tr><td class="space_footer" style="padding:0;"> </td>
</tr><tr><td class="footer" style="border-top:4px solid #333333;padding:7px 0;"><span><a href="{shop_url}" style="color:#337ff1;">{shop_name}</a> powered by <a href="http://www.prestashop.com/" style="color:#337ff1;">PrestaShop™</a></span></td>
</tr></tbody></table></td>
<td class="space" style="width:20px;padding:7px 0;"> </td>
</tr></tbody></table>

Here is what the email looked like:

 

Customer message: has been installed on:http://localhost/

Customer Name: {FIRSTNAME} {LASTNAME}


Customer Name: 


Billing Address: 
Attached file: {attached_file}

 

The Customer Name and Billing Address lines in the email are empty

Edited by vinhhoa1 (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...