updating index.php and fixing js error