Validate form
This commit is contained in:
parent
24622917fe
commit
451bb54c50
@ -10,7 +10,7 @@ class Process
|
||||
{
|
||||
$this->mail_dir = dirname(__FILE__);
|
||||
|
||||
$_to = Db::getInstance()->ExecuteS("SELECT email FROM "._DB_PREFIX_."contactform_email");
|
||||
$_to = Db::getInstance()->ExecuteS('SELECT email FROM '._DB_PREFIX_.'contactform_email');
|
||||
foreach ($_to as $k => $email) {
|
||||
$this->to[] = $email;
|
||||
}
|
||||
@ -24,37 +24,41 @@ class Process
|
||||
if (!$isCorrect) {
|
||||
$errors[] = 'Tous les champs ne sont pas remplis';
|
||||
} else {
|
||||
$query = Db::getInstance()->autoExecute(_DB_PREFIX_.'contactform', [
|
||||
'brand' => pSQL($this->data['brand']),
|
||||
'compagny' => pSQL($this->data['compagny']),
|
||||
'lastname' => pSQL($this->data['lastname']),
|
||||
'firstname' => pSQL($this->data['firstname']),
|
||||
'function' => pSQL($this->data['function']),
|
||||
'email1' => pSQL($this->data['email1']),
|
||||
'email2' => pSQL($this->data['email2']),
|
||||
'phone1' => pSQL($this->data['phone1']),
|
||||
'phone2' => pSQL($this->data['phone2']),
|
||||
'purpose' => pSQL($this->data['purpose']),
|
||||
'content' => pSQL($this->data['content']),
|
||||
'type' => Contactform::TYPE_PROVIDER
|
||||
], 'INSERT');
|
||||
|
||||
if (!$query) {
|
||||
$errors[] = "Une erreur s'est produite. Votre message n'a pas été envoyé";
|
||||
if (!Validate::isEmail($tthis->data['email1']) || !(Validate::isEmail($tthis->data['email1']) && Validate::isEmail($tthis->data['email2']))) {
|
||||
$errors[] = 'Certains champs ne sont pas valide';
|
||||
} else {
|
||||
Mail::Send(
|
||||
intval($cookie->id_lang),
|
||||
'provider',
|
||||
'sujet',
|
||||
$this->data,
|
||||
$this->to,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
$this->mail_dir
|
||||
);
|
||||
$query = Db::getInstance()->autoExecute(_DB_PREFIX_.'contactform', [
|
||||
'brand' => pSQL($this->data['brand']),
|
||||
'compagny' => pSQL($this->data['compagny']),
|
||||
'lastname' => pSQL($this->data['lastname']),
|
||||
'firstname' => pSQL($this->data['firstname']),
|
||||
'function' => pSQL($this->data['function']),
|
||||
'email1' => pSQL($this->data['email1']),
|
||||
'email2' => pSQL($this->data['email2']),
|
||||
'phone1' => pSQL($this->data['phone1']),
|
||||
'phone2' => pSQL($this->data['phone2']),
|
||||
'purpose' => pSQL($this->data['purpose']),
|
||||
'content' => pSQL($this->data['content']),
|
||||
'type' => Contactform::TYPE_PROVIDER
|
||||
], 'INSERT');
|
||||
|
||||
if (!$query) {
|
||||
$errors[] = 'Une erreur s\'est produite. Votre message n\'a pas été envoyé';
|
||||
} else {
|
||||
Mail::Send(
|
||||
intval($cookie->id_lang),
|
||||
'provider',
|
||||
'sujet',
|
||||
$this->data,
|
||||
$this->to,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
$this->mail_dir
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,35 +76,39 @@ class Process
|
||||
if (!$isCorrect) {
|
||||
$errors[] = 'Tous les champs ne sont pas remplis';
|
||||
} else {
|
||||
$query = Db::getInstance()->autoExecute(_DB_PREFIX_.'contactform', [
|
||||
'compagny' => pSQL($this->data['compagny']),
|
||||
'lastname' => pSQL($this->data['lastname']),
|
||||
'firstname' => pSQL($this->data['firstname']),
|
||||
'function' => pSQL($this->data['function']),
|
||||
'email1' => pSQL($this->data['email1']),
|
||||
'email2' => pSQL($this->data['email2']),
|
||||
'phone1' => pSQL($this->data['phone1']),
|
||||
'phone2' => pSQL($this->data['phone2']),
|
||||
'content' => pSQL($this->data['content']),
|
||||
'type' => Contactform::TYPE_PRESS
|
||||
], 'INSERT');
|
||||
|
||||
if (!$query) {
|
||||
$errors[] = "Une erreur s'est produite. Votre message n'a pas été envoyé";
|
||||
if (!Validate::isEmail($tthis->data['email1']) || !(Validate::isEmail($tthis->data['email1']) && Validate::isEmail($tthis->data['email2']))) {
|
||||
$errors[] = 'Certains champs ne sont pas valide';
|
||||
} else {
|
||||
Mail::Send(
|
||||
intval($cookie->id_lang),
|
||||
'press',
|
||||
'sujet',
|
||||
$this->data,
|
||||
$this->to,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
$this->mail_dir
|
||||
);
|
||||
$query = Db::getInstance()->autoExecute(_DB_PREFIX_.'contactform', [
|
||||
'compagny' => pSQL($this->data['compagny']),
|
||||
'lastname' => pSQL($this->data['lastname']),
|
||||
'firstname' => pSQL($this->data['firstname']),
|
||||
'function' => pSQL($this->data['function']),
|
||||
'email1' => pSQL($this->data['email1']),
|
||||
'email2' => pSQL($this->data['email2']),
|
||||
'phone1' => pSQL($this->data['phone1']),
|
||||
'phone2' => pSQL($this->data['phone2']),
|
||||
'content' => pSQL($this->data['content']),
|
||||
'type' => Contactform::TYPE_PRESS
|
||||
], 'INSERT');
|
||||
|
||||
if (!$query) {
|
||||
$errors[] = 'Une erreur s\'est produite. Votre message n\'a pas été envoyé';
|
||||
} else {
|
||||
Mail::Send(
|
||||
intval($cookie->id_lang),
|
||||
'press',
|
||||
'sujet',
|
||||
$this->data,
|
||||
$this->to,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
$this->mail_dir
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ include_once(dirname(__FILE__).'/Process.php');
|
||||
include(dirname(__FILE__).'/../../header.php');
|
||||
|
||||
$result = null;
|
||||
if (!empty($_POST['type'])) {
|
||||
if (Tools::isSubmit('press_form')) {
|
||||
$Process = new Process();
|
||||
$result = $Process->addPress($_POST);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@
|
||||
|
||||
<input type="hidden" name="type" value="{Contactform::TYPE_PRESS}">
|
||||
|
||||
<button type="submit" id="SubmitLogin" class="module-contactform-button">{l s='Envoyer' mod='contactform'}</button>
|
||||
<button type="submit" id="SubmitLogin" class="module-contactform-button" name="press_form">{l s='Envoyer' mod='contactform'}</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
@ -8,7 +8,7 @@ include_once(dirname(__FILE__).'/Process.php');
|
||||
include(dirname(__FILE__).'/../../header.php');
|
||||
|
||||
$result = null;
|
||||
if (!empty($_POST['type'])) {
|
||||
if (Tools::isSubmit('provider_form')) {
|
||||
$Process = new Process();
|
||||
$result = $Process->addProvider($_POST);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@
|
||||
|
||||
<input type="hidden" name="type" value="{Contactform::TYPE_PROVIDER}">
|
||||
|
||||
<button type="submit" id="SubmitLogin" class="btn_box login_box module-contactform-button">{l s='Envoyer' mod='contactform'}</button>
|
||||
<button type="submit" id="SubmitLogin" class="btn_box login_box module-contactform-button" name="provider_form">{l s='Envoyer' mod='contactform'}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user