Search the Community
Showing results for tags 'php terminate'.
-
how to terminate everything and only show the error message
et4891 posted a topic in PHP Coding Help
I kind of posted this code earlier but earlier I had other question anyways I ran into another situation and got stuck again..... ok I made this drop list and I only make it to show all .txt files in the current folder and made it to have error if there's NO .txt files in the folder but I want the error to show with ONLY the error message but somehow what I'm doing now shows the drop list with nothing in the drop list and the error message. How can I make it so it only shows the error message only and shows nothing else? This is my coding: <?php if(!(is_dir("./aaa"))) { die("Must create a <strong>aaa</strong> folder first, sorry"); } echo "<form action=\"./page2.php\" method=\"get\">"; echo "<select name=\"aaa\">"; $aaa_files = scandir("./aaa"); $hastxt = false; foreach($aaa_files as $file_list) { $file_list = strtolower($file_list); if(($file_list == ".") || ($file_list == "..")) { continue; } if(strlen($file_list)>4 && strtolower(substr($file_list, -4))!='.txt') { continue; } else { $hastxt = true; echo "<option value=\""; echo basename($file_list,".txt"); echo "\">"; echo basename($file_list,".txt"); echo "</option>"; } } echo "</select>"; echo "<br/><input type=\"submit\">"; echo "</form>"; if($hastxt == false) { echo "Must create text files first, sorry"; die(); } ?> ----------------------------------------------------------------- This is what shows if I don't have any txt file in the folder but what I want it to so is something like the image below ----------------------------------------------------------------- This is how I want the error message to show...but of course without the arrow...just plain error message nothing else....