1

I implemented OTP integration. Now in table 'otpp' I have column 'verified'='0' when user doesn't verify OTP and 'verified'='1' if user verified. So I need to redirect to otp verification page when 'verified' is '0'. I hope will get help. This is my block for otp verification:

public function checkotp(){


$uid = $this->getCustomerId();
//db connection
$this->_resources = \Magento\Framework\App\ObjectManager::getInstance()
->get('Magento\Framework\App\ResourceConnection');  
$connection= $this->_resources->getConnection();
$tableName = $this->_resources->getTableName('otpp');

$ckotp = $_POST["getotp"];

$dates = date("Y-m-d");

    // SELECT DATA
/*$sql = "SELECT otp FROM otpp WHERE  'entity_id' = '$uid'";
$result = $connection->fetchall($sql); 
$cd = $result['0'];
$dc = $cd['otp'];
*/

$dc = $this->getOtp();

if($dc === $ckotp){


    $uid = $this->getCustomerId();
    $this->_resources = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\App\ResourceConnection');   
    $connection= $this->_resources->getConnection();
    $tableName = $this->_resources->getTableName('otpp');
    $mobile = $this->getId();
    $sql = "UPDATE `otpp` SET `phone` = '$mobile', `verified` = '1' WHERE entity_id = '$uid' ";  
    echo "<div class='success'>";
    echo "Your mobile number verified";
    echo "</div>";
    header("Location: http://locahost/otp/index/success");

}

elseif($dc != $ckotp){

   $url = header("Location: http://localhost/otp/index/reenter");
   return $url;

}

else{
   $url = header("Location: http://localhost/otp/index/reenter");
   return $url;

}

$connection->query($sql); 

}

Here my Block for redirection if otp verification is 0

public function userRedirect(){

    $suser_id = $this->getCustomerId();
    $this->_resources = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Framework\App\ResourceConnection');   
    $connection= $this->_resources->getConnection();
    $tableName = $this->_resources->getTableName('otpp');
    $sql = "SELECT verified FROM otpp WHERE `entity_id`='$suser_id'";

    $result = $connection->fetchall($sql);
    $otparray = $result['0']; 
    $verified = $otparray['verified'];
            if ($verified = 0) {
            $redirect = $this->response->setRedirect('otp/index/reenter');
        }

        return $redirect;

}
1
  • 1
    Ramesh could you please explain your question in detail, what you want to achieve, what you have done till now. With some screenshots and code snippets. This will help others to understand your question and provide you the helpful answer. Nov 24, 2017 at 10:09

1 Answer 1

0
 return $resultRedirect->setUrl($this->_redirect->getRefererUrl());

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.