Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Display Error

$
0
0
In Yii how to check a value exist in the database and if its not exist, shows error message below the text box. In controller checks the value is exist, but how show error below the text box when value doesn't exist?
if(isset($_POST['Security']))
             {
                 $answer=$_POST['Security']['security_ans1'];
                 if($answer==$ans)
                 {
                     
                      $this->redirect(array('/postRequest/default/index')); 
                 }
                 else
                 {
                    echo 'error';

                 }
               
             }

Form is
div class="row">
                <?php echo $form->labelEx($model,'Answer'); ?>
                <?php echo $form->textField($model,'security_ans1',array('size'=>30,'maxlength'=>50)); ?>
                <?php echo $form->error($model,'security_ans1'); ?></td>
        </div>
         
        <div class="row buttons">
            <?php  echo CHtml::submitButton('Submit'); ?>

Thanks

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>