0

i m using ajax to insert variable into database i have two input box one is email other is company name i m using filter_var to check email validation but now problem is how to insert company name without used this validation?

Here is my code

<?php 
 require_once('app/Mage.php');
 ini_set('display_errors', 1);
 Mage::app('admin');
 $resource = Mage::getSingleton('core/resource');
 $writeConnection = $resource->getConnection('core_write');
 $company = $_REQUEST['company'];
 $email = $_REQUEST['email'];
 $email = filter_var($email, FILTER_SANITIZE_EMAIL);
 if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
 $query = "INSERT INTO guest_user_track(Guser_mail,Guser_name) VALUES 
 ('{$email}','{$company}')";
$writeConnection->query($query);
echo json_encode(array("message"=>"success"));
}
else {
 echo json_encode(array("message"=>"error"));
}
Naveed Asim
3,6892 gold badges12 silver badges23 bronze badges
asked Mar 24, 2018 at 6:53
0

1 Answer 1

0

For Validation i suggest you should use Zend framework validation and for text based validation you should use : Zend_Validate_Alpha

you can check following link with all validation and patterens

http://framework.zend.com/manual/1.12/en/zend.validate.set.html

hope it will help

answered Mar 24, 2018 at 7:14
2
  • my problem is not validation working ...actually my email validation response is correct but i want to insert company name and email(after validation) but its only inserting email not name. because name also using mail validation i thnk so i want to know how to use this validation so i can insert both variable in my database Commented Mar 24, 2018 at 7:18
  • i suggest you should use Zend_framework validation which is builtin supported, otherwise you have use regex with filter_var for logic implementation. Secondly i assume your form validation pass through and only issue is on server side. Commented Mar 24, 2018 at 7:21

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.