Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End using exceptions

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #30081
    thisishard
    Member

    Hi, this is my current exception,


    try
    {
    if(!$this->isDataValid())
    throw new Exception('You Have Entered Invalid Characters In The Form.');
    if(!$this->checkToken())
    throw new Exeption('Please Try Again Later, Or Contact Us For Help.');
    if(!$this->sendToDB())
    throw new Exeption('You Have Entered An Incorect Email Or Password.');
    }
    catch(Exception $e)
    {
    $this->_formErrors[] = $e->getMessage();
    }

    With this, the isDataValid is going to prevent sql injection by causing an error if it finds invalid characters, If it does find invalid characters will the exception end right there or will it carry on and run the other two ‘if’s’ and then flag the error? I don’t want it to find invalid characters and then run the sendToDB function because that would defeat the purpose of having the isDataValid function.

    Many Thanks
    Chris

    #81032
    MrSoundless
    Member

    If an Exception is thrown, nothing will run until the catch is reached. The code will continue running starting from the catch.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.