Jump to content

Contact form extra fields added but validation applies


Recommended Posts

I hope someone can help. I have made a modified contact form (based on contact.php) to take specific data from the customer. However the code I copied has the same validation rules as name and email. ie if blank throw error ...can not be blank. However I want to make these fields optional.
The code as it stands with all fields required works all the to the email arriving with all field data correct. However if I comment out the corresponding part of the elseif statements (see below) the email can still send but I will not recieve the data entered into the country field.

/*elseif (!($Country = nl2br2(Tools::getValue('Country'))))
$errors[] = Tools::displayError('Country cannot be blank');*/

after the string of these elseif statements is:



if (intval($cookie->id_customer))
$customer = new Customer(intval($cookie->id_customer));
if (Mail::Send(intval($cookie->id_lang), 'custom-contact', 'Message from contact form', array('{email}' => $from, '{message}' => stripslashes($message),'{name}' => stripslashes ( $name ), '{lastname}' => stripslashes ( $lastname ), '{city}' => stripslashes ( $city ), '{Country}' => stripslashes ( $Country ), '{telephone}' => ($telephone ), '{weddingdate}' => stripslashes ( $weddingdate ),'{fittingdate}' => stripslashes ( $fittingdate )), $contact->email, $contact->name, $from, (intval($cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : $from)))

This is pretty much the last thing stopping my site going live so ideas would be amazing!!! A solution even better!!

Share this post

Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More