|
|
|
|
![]() ![]() |
Dec 15 2007, 02:27 PM
Post
#1
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 102 Joined: 25-November 07 Member No.: 53,695 |
edit:sorry for the mistake it is php not html
and its with not whith my code checking script= CODE <?php $file = '$CHECK'; if (file_exists($file)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; } ?> my question is how to check the file whith html example:on a page a text box is provided and a button the user writes a file name (or website) the user clicks on the submit button then it checks and show it (with the code above) i got the code CODE <?php $filename=$_POST['check']; if (file_exists($filename)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; } ?> <form method="post"> <input name="check"> <input type="submit" /> </form> but...... the problem is , it will first show $_POST['check'] or Notice: Undefined index: check in path\to\filecheck.php on line 2 The file does not exist This post has been edited by mahirharoon: Dec 15 2007, 02:32 PM |
|
|
|
Dec 18 2007, 02:40 AM
Post
#2
|
|
|
Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 1,074 Joined: 25-September 05 From: Los Angeles, California Member No.: 12,251 |
You can tell php to hide errors such as this if you put an at symbol (@) before the function returning the error.
i.e. CODE if(@file_exists($filename)){
|
|
|
|
Dec 22 2007, 06:59 AM
Post
#3
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 102 Joined: 25-November 07 Member No.: 53,695 |
thanks alex the programmer
i used it for my project CODE <?php $filename=$_POST['check']; if (@file_exists($filename)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist , and the non existing file is created"; fopen("$filename", "a+"); } ?> <form method="post"> <input name="check"> <input type="submit" /> </form> now it checks whether it i there and makes one if not existing This post has been edited by mahirharoon: Dec 22 2007, 07:06 AM |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 13th October 2008 - 12:43 AM |