-3
<--- this is my view-->
<?php 
    if ($exec == 'true'){
        echo '<script type="text/javascript">
        alert("email alreay exist");
        </script>'
    }
?>
<?php endif; ?>

<-- this is my controller -->
function email_taken($input){

    $query="select * from dentaldoctors  where email='$input'";
    $exec=$this->db->query($query) or die(mysql_error());

    if($exec) {
        true
    } else {
        FALSE;
    }
}
Tom
  • 4,257
  • 6
  • 33
  • 49
suhail ahmed
  • 122
  • 1
  • 12

3 Answers3

1

What is the following doing?

<?php endif; ?>

You're closing a non existent if statement - based on the code you've given.

Tom
  • 4,257
  • 6
  • 33
  • 49
  • From the edit history it shows that the OP did not have that end if it shows that you are the one that put it there see [Your edit](http://stackoverflow.com/revisions/43864635/2) Against [OP's edit](http://stackoverflow.com/revisions/43864635/1) – Masivuye Cokile May 09 '17 at 08:37
  • 1
    @MasivuyeCokile Actually, if you look at the source of the original post - http://stackoverflow.com/revisions/73b2a8c0-598a-4cd9-b8d4-0eb7bd2604d4/view-source - you'll see that the `` is already there. I just formatted it correctly. – Tom May 09 '17 at 08:39
  • 1
    @MasivuyeCokile You've also therefore rolled back a completed fine edit. Do you know what you're doing? – Tom May 09 '17 at 08:40
0

You are missing semicolon in both of if statement

View

if ($exec == 'true'){
    echo '<script type="text/javascript">
    alert("email alreay exist");
    </script>';
}

Controller

if($exec) {
    true;
} else {
    FALSE;
}

Please replace your code as per above explanation. i hope it will work for you !

Devdutt Sharma
  • 391
  • 1
  • 2
  • 10
0

SIMPLE ANSWER. REMOVE THE <?php endif; ?> FROM YOUR CODE AND IT WORKS LIKE A CHARM. ALSO, ADD ; AT THE END OF echo STATEMENT

xXAlphaManXx
  • 161
  • 1
  • 6