After you posted the sources, I think I know what is wrong:
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
echo '<script type="text/javascript">alertify.alert("Hello");</script>';
}
?>
is located above the script tag that loads your javascript. This means that any code in the PHP segment is executed before that code. In other words, alertify has not yet been defined there.
To resolve this, place a PHP echo inside the head, below the include for alertify, or include the alertify as a separate echo in the PHP, example:
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
echo '<script type="text/javascript" src="alertify.js"></script>'
echo '<script type="text/javascript">alertify.alert("Hello");</script>';
}
?>