Jump to content

Problema contact form


neomed

Recommended Posts

Salut,

Am o problema si nu stiu ce sa ii fac.

M-am uitat pe net cum se adauga nume, oras, telefon in plus pe contact form si am gasit dar cand am facut cum mi s-a zis nu imi merge.

am asa:

1. contact-form.php

am asa

require(dirname(__FILE__).'/config/config.inc.php');
ControllerFactory::getController('ContactController')->run();

2.

{capture name=path}{l s='Contact'}{/capture}
{include file="$tpl_dir./breadcrumb.tpl"}
<h1>{l s='Customer Service'} - {if isset($customerThread) && $customerThread}{l s='Your reply'}{else}{l s='Contact us'}{/if}</h1>
{if isset($confirmation)}
<p>{l s='Your message has been successfully sent to our team.'}</p>
<ul class="footer_links">
 <li><a href="{$base_dir}"><img class="icon" alt="" src="{$img_dir}icon/home.gif"/></a><a href="{$base_dir}">{l s='Home'}</a></li>
</ul>
{elseif isset($alreadySent)}
<p>{l s='Your message has already been sent.'}</p>
<ul class="footer_links">
 <li><a href="{$base_dir}"><img class="icon" alt="" src="{$img_dir}icon/home.gif"/></a><a href="{$base_dir}">{l s='Home'}</a></li>
</ul>
{else}
<p class="bold">{l s='For questions about an order or for more information about our products'}.</p>
{include file="$tpl_dir./errors.tpl"}
<form action="{$request_uri|escape:'htmlall':'UTF-8'}" method="post" class="std" enctype="multipart/form-data">
 <fieldset>
  <h3>{l s='Send a message'}</h3>
  <p class="select">
   <label for="id_contact">{l s='Subject Heading'}</label>
  {if isset($customerThread.id_contact)}
   {foreach from=$contacts item=contact}
 {if $contact.id_contact == $customerThread.id_contact}
  <input type="text" id="contact_name" name="contact_name" value="{$contact.name|escape:'htmlall':'UTF-8'}" readonly="readonly" />
  <input type="hidden" name="id_contact" value="{$contact.id_contact}" />
 {/if}
   {/foreach}
  </p>
  {else}
   <select id="id_contact" name="id_contact" onchange="showElemFromSelect('id_contact', 'desc_contact')">
 <option value="0">{l s='-- Choose --'}</option>
   {foreach from=$contacts item=contact}
 <option value="{$contact.id_contact|intval}" {if isset($smarty.post.id_contact) && $smarty.post.id_contact == $contact.id_contact}selected="selected"{/if}>{$contact.name|escape:'htmlall':'UTF-8'}</option>
   {/foreach}
   </select>
  </p>
  <p id="desc_contact0" class="desc_contact"> </p>
   {foreach from=$contacts item=contact}
 <p id="desc_contact{$contact.id_contact|intval}" class="desc_contact" style="display:none;">
  <label> </label>{$contact.description|escape:'htmlall':'UTF-8'}
 </p>
   {/foreach}
  {/if}
  <p class="text">
   <label for="name">{l s='Name and Last Name'}</label>
   {if isset($customerThread.name)}
 <input type="text" id="name" name="from" value="{$customerThread.name}" readonly="readonly" />
   {else}
 <input type="text" id="name" name="from" value="{$name}" />
   {/if}
   <sup style="color:red;">*</sup>
  </p>
  <p class="text">
   <label for="city">{l s='City'}</label>
   {if isset($customerThread.city)}
 <input type="text" id="city" name="from" value="{$customerThread.city}" readonly="readonly" />
   {else}
 <input type="text" id="city" name="from" value="{$s}" />
   {/if}
   <sup style="color:red;">*</sup>
  </p>
  <p class="text">
   <label for="telephone">{l s='Telephone'}</label>
   {if isset($customerThread.telephone)}
 <input type="text" id="telephone" name="from" value="{$customerThread.telephone}" readonly="readonly" />
   {else}
 <input type="text" id="telephone" name="from" value="{$telephone}" />
   {/if}
   <sup style="color:red;">*</sup>
  </p>
  <p class="text">
   <label for="email">{l s='E-mail address'}</label>
   {if isset($customerThread.email)}
 <input type="text" id="email" name="from" value="{$customerThread.email}" readonly="readonly" />
   {else}
 <input type="text" id="email" name="from" value="{$email}" />

   {/if}
   <sup style="color:red;">*</sup>
  </p>
 {if !$PS_CATALOG_MODE}
  {if (!isset($customerThread.id_order) || $customerThread.id_order > 0)}
  <p class="text">
   <label for="id_order">{l s='Order ID'}</label>
   {if !isset($customerThread.id_order) && isset($isLogged) && $isLogged == 1}
 <select name="id_order" ><option value="0">{l s='-- Choose --'}</option>{$orderList}</select>
   {elseif !isset($customerThread.id_order) && !isset($isLogged)}
 <input type="text" name="id_order" id="id_order" value="{if isset($customerThread.id_order) && $customerThread.id_order > 0}{$customerThread.id_order|intval}{else}{if isset($smarty.post.id_order)}{$smarty.post.id_order|intval}{/if}{/if}" />
   {elseif $customerThread.id_order > 0}
 <input type="text" name="id_order" id="id_order" value="{$customerThread.id_order|intval}" readonly="readonly" />
   {/if}
  </p>
  {/if}
  {if isset($isLogged) && $isLogged}
  <p class="text">
  <label for="id_product">{l s='Product'}</label>
   {if !isset($customerThread.id_product)}
 <select name="id_product" style="width:300px;"><option value="0">{l s='-- Choose --'}</option>{$orderedProductList}</select>
   {elseif $customerThread.id_product > 0}
 <input type="text" name="id_product" id="id_product" value="{$customerThread.id_product|intval}" readonly="readonly" />
   {/if}
  </p>
  {/if}
 {/if}
 {if $fileupload == 1}
  <p class="text">
  <label for="fileUpload">{l s='Attach File'}</label>
   <input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
   <input type="file" name="fileUpload" id="fileUpload" />
  </p>
 {/if}
 <p class="textarea">
  <label for="message">{l s='Message'}</label>
   <textarea id="message" name="message" rows="15" cols="20" style="width:340px;height:220px">{if isset($message)}{$message|escape:'htmlall':'UTF-8'|stripslashes}{/if}</textarea>
 </p>
 <p class="submit">
  <input type="submit" name="submitMessage" id="submitMessage" value="{l s='Send'}" class="button_large" onclick="$(this).hide();" />
 </p>
</fieldset>
</form>
{/if}

3. ContactController.php

  $message = Tools::htmlentitiesUTF8(Tools::getValue('message'));
  if (!($from = trim(Tools::getValue('from'))) OR !Validate::isEmail($from))
   $this->errors[] = Tools::displayError('Invalid e-mail address');
  elseif (!($name = nl2br2($name)))
   $this->errors[] = Tools::displayError('Name cannot be blank');
  elseif (!($city = nl2br2($city)))
   $this->errors[] = Tools::displayError('City cannot be blank');
  elseif (!($telephone = nl2br2($telephone)))
   $this->errors[] = Tools::displayError('Telephone cannot be blank');
  elseif (!($message = nl2br2($message)))
   $this->errors[] = Tools::displayError('Message cannot be blank');
  elseif (!Validate::isCleanHtml($message))
   $this->errors[] = Tools::displayError('Invalid message');
  elseif (!($id_contact = (int)(Tools::getValue('id_contact'))) OR !(Validate::isLoadedObject($contact = new Contact((int)($id_contact), (int)(self::$cookie->id_lang)))))
   $this->errors[] = Tools::displayError('Please select a subject on the list.');
  elseif (!empty($_FILES['fileUpload']['name']) AND $_FILES['fileUpload']['error'] != 0)
   $this->errors[] = Tools::displayError('An error occurred during the file upload');
  elseif (!empty($_FILES['fileUpload']['name']) AND !in_array(substr($_FILES['fileUpload']['name'], -4), $extension) AND !in_array(substr($_FILES['fileUpload']['name'], -5), $extension))
   $this->errors[] = Tools::displayError('Bad file extension');
  else
  {
   if ((int)self::$cookie->id_customer)
 $customer = new Customer((int)(self::$cookie->id_customer));
   else
   {
 $customer = new Customer();
 $customer->getByEmail($from);
   }
   $contact = new Contact((int)$id_contact, (int)self::$cookie->id_lang);

...

if (Mail::Send((int)(self::$cookie->id_lang), 'contact', Mail::l('Message from contact form'), array('{email}' => $from, '{message}' => stripslashes($message), '{city}' => stripslashes ( $city ), '{telephone}' => stripslashes ( $telephone), '{names}' => stripslashes ( $name)), $contact->email, $contact->name, $from, ((int)(self::$cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : ''), $fileAttachment)
  AND Mail::Send((int)(self::$cookie->id_lang), 'contact_form', Mail::l('Your message has been correctly sent'), array('{email}' => $from, '{message}' => stripslashes($message), '{name}' => stripslashes ( $name ), '{telephone}' => stripslashes ( $telehone ), '{city}' => stripslashes ( $city )), $from))
				    self::$smarty->assign('confirmation', 1);

acestea sunt cele pe care le-am modificat.

Nu stiu de ce imi tot da

 

Exista 1 eroare :[list=1]
[*]Name cannot be blank
[/list]

si nu imi mai trimite nimic.

Va rog sa imi explicati pentru ca eu am facut pasii din tutorial.

Va multumesc cu stima Trif

Link to comment
Share on other sites

×
×
  • Create New...