Nov 21, 2009

File Checker-how To Check File Whith Html Through Html?

free web hosting
Open Discussion > MODERATED AREA > Computers > Programming Languages > PHP Programming

File Checker-how To Check File Whith Html Through Html?

mahirharoon
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

 

 

 


Comment/Reply (w/o sign-up)

alex7h3pr0gr4m3r
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)){

Comment/Reply (w/o sign-up)

mahirharoon
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

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : file, checker, check, file, whith, html, html,

  1. Php - Fetching Random Line From A Text File
    and displaying it using AJAX/iframe (0)
  2. Weird Formatting: Embedding Php Into Html
    (10)
    I have a funny problem when I embed PHP in a HTML page whenever I write some PHP code with the
    'print' or 'echo' command, the output shows the end bits of the PHP code, eg. when I
    write: CODE print "This is PHP"; ?> the output I get is: This is PHP";?> So, the final
    quote mark, the semicolon and the ending PHP tags are displayed. Has anyone else come across this
    problem before, and does anyone know a solution for it? By the way, the full code would be: CODE
    Some HTML print "This is PHP"; ?> The funny thing is, this does not ....
  3. Linux/ Apache /mod_rewrite Issue
    Error when accessing a file (4)
    running on Ubuntu 8.04 with an XAMPP - php5.2.5, Apache 2., etc Getting this error when I try to
    access an sNews CMS which requires mod_rewrite and is installed locally: QUOTE Apache/2.2.8
    (Unix) DAV/2 mod_ssl/2.2.8 OpenSSL/0.9.8e PHP/5.2.5 mod_apreq2-20051231/2.6.0 mod_perl/2.0.2
    Perl/v5.10.0 configured -- resuming normal operations /opt/lampp/htdocs/jim/snews/.htaccess:
    RewriteBase: argument is not a valid URL /opt/lampp/htdocs/jim/snews/.htaccess: RewriteBase:
    argument is not a valid URL Using this link: http://localhost/jim/snews/snews16_ema....
  4. Html Form!
    Using MySQL?! (4)
    Hey, I need your help again! I need some good working tutorial how I can update my SQL through HTML
    form. I did use some tutorials online found with the help of google; but they do not work properly;
    I mean there are still small mistakes. I need to have a good tutorial to follow. It should be
    based on security and more things. It has to be done in proper way.......
  5. Php Configuration File
    "config.php" (18)
    I did create this topic mainly because I want to know everything about that configuration file. I
    will post other replies if I want to know more depending on your experience. Is this code correct
    for that file: CODE $host="localhost"; $dbname="XXX"; $dbuser="XXX"; $dbpass="XXX";
    $connection=mysql_connect($host, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname)
    or die(mysql_error()); ?> Add your suggestions or improve it.....
  6. Need Some Help In File Browser
    listing all sub folders and files in them. (8)
    Hey I want to create a very simple file browser, so that, it reads all the sub-folders which are
    places in a directory, and the files inside the sub-folders (It reads only files inside sub-folders
    and list them in simply. ) Also, it creates a directory (any name) inside each sub folder. My
    Following code reads on the files inside the main directory, it does not read the files inside the
    sub-folders.. I appreciate any help. CODE $path = "./"; $dir_handle = @opendir($path) or
    die("Unable to open $path"); while ($file = readdir($dir_handle)) { if($file == "." || $fil....
  7. How Do I Get The Result To "stick" And Add Html Tags?
    Help please? (14)
    $changepage = $_REQUEST ; echo " $changepage "; ?> Okay, I need a way for any
    information typed in my textarea to "stick" on the page in which it "posts". Since I am creating a
    way for my registered users to decorate their "homepages". So any help, tutorials, etc. would be
    greatly appreciated. ^^ Thanks.....
  8. Updating Php File Through A Web Form
    (5)
    Hello, i'm not sure if this can be done with php or not but what i need is a way to make an php
    file that have an html form on it and it will take the info you put in to that form and write it to
    an existing php file, for example: if i have the file news.php and the file news_update.php. if you
    went to news_update.php you would get an form with a text area for you to write a new addition for
    the news.php file and when you hit submit it will add what you typed in the form to the file
    news.php. If this is going to be a big code or a hard one to make but some one think....
  9. Html Code Tester. Online Script
    (15)
    Yes, yes. I have another script that I have written and I am distributing. I am not entirely sure if
    this works. I have not tested it yet, but I will later and post back with a demo and fix it up.
    Current script: CODE //Save this as something like htmltest.php function CheckForm() {
    $html_unsafe=$_POST ; //Gives us our user input $html_safe=str_replace(" //Starts security measures
    $html_safe=str_replace("?>"," ",$html_safe); //User input now secure server side //Still security
    issues client side echo $html_safe; //echos our statement } //End function //Main script....
  10. Html Site With Login
    Is it possible? (2)
    Hello. I´m building my own site and I need some help... Is it possible to use a login sistem in php
    and mysql database in a html site? ....
  11. Script To Translate Into Bbcode From Html Tags
    (1)
    I was wanting to know how to make a form like they use here for the website form. I want to be able
    to turn stuff in to bbcode. If you know how or would be willing to write the script for me could
    you email me. will@darkzone3.com . I am william to give all credit to who ever makes it. and i can
    put a link back to a site if you want. Please be specific with the topic title. "Help" is never a
    good topic title. This is explained in our forum rules. Title modified. ....
  12. Php And Flash Image Gallery
    Need some help in creating or editing an xml file while viewing some o (5)
    Hello there and thanks for the helping hand you are offering. PHP newbie here! /ph34r.gif"
    style="vertical-align:middle" emoid=":ph34r:" border="0" alt="ph34r.gif" /> So here is my problem:
    On my website I have a flash image gallery.The way the gallery works is by uploading pictures in a
    folder and editing? an xml file.(pics.xml) where it adds the following code when you upload a
    picture: CODE           etc... Now I have users that upload products they sell on the
    website or they advertise their business(hotels, jewellers, car resellers,...) So for eve....
  13. No File Extension
    (3)
    On MediaWiki, the URL of the content is http://YOURWIKI.com/index.php/Blah Is it possible to
    create a page or two that doesn't have a file extension? If so, how is it done?....
  14. File Upload
    File upload (1)
    I need to add a facility on my customer's website so his clients can send him jobs, typically
    5mb - 50mb. I've looked around the web and researched this, and tried a few tests (failed), but
    my brain's beginning to hurt. Could someone please tell me the best way to go about this,
    please. The site is done in Flash, but I'm sure a link to an html page would be ok if necessary.....
  15. <?php ?> Unique Visitors Script
    Flat file unique visitors script (no sessions) (2)
    This is really simple script. Well at least this part is, but it could be extendable. Only problem
    is that it's not really for massive websites with hundread of visitors a day, but rather for
    small ones. But it is a good script to figure out how to make a visitor counter script. Anyway
    here's the snippet. CODE function getVisits($variable) {     $visits = array();     if
    ($handle = opendir('stats/')) {     while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {             array_push($visits, $file);         } ....
  16. <?php ?> Marking Up With Php
    How to simply add HTML tags with PHP (0)
    Just a simple function to mark your queries /smile.gif" style="vertical-align:middle" emoid=":)"
    border="0" alt="smile.gif" /> CODE $uzorak = 'Hosting credit'; //use post to get
    $uzorak variable $tapeti = "Hosting credits are collected by posting at the forums. The hosting
    credits are given after your posts are filtered and depending on its size, you get proportional
    hosting credits. Once you get the required credits you can post an application for hosting. One of
    our admins will then approve your application after which you can register an account at ht....
  17. [php]simple Flat File Text Manipulator
    Example on how to use forms to write to files in PHP (3)
    I made a simple flat file text editor, that can show you probably how simple it is to use forms with
    php and write that data to file. This example has 2 files, submit.php, and postit.html. Submit.php
    is used to write title, and some text, and add html tags, and paragraph tags where new paragraphs
    are. Here's the file with comments. I think that HTML really doesn't need some more
    explaining. CODE Title: Text: if (@$_POST =="" || @$_POST
    ==""){      echo "Enter text to save!"; } else {      //this is path to file      $filena....
  18. Edit .txt File In Ftp Via Webpage
    file on external ftp (2)
    Right Im new here and stuggling with a problem im having. I've currently got a Login Script to
    login to a external ftp and it displays the folders contents, however i need it so it echos a
    specific file (coursedata.cfg) into a formarea which you can then edit the file and when u click
    save it overwrites the file with the new one. Im really quiet getting annoyed with it xD as
    everything i do ends up trying to include the file from the webserver the script is hosted on and
    not the external ftp source. thanks Full Code Bellow Simple FTP Manager body { fon....
  19. Help With Moving Html Form Results To Shopping Cart?
    (3)
    Hello All- So I think I'm tackling a pretty big project here and was looking for some help... I
    am fairly new to extensive coding (beyond HTML and a little bit of JavaScript) and wanted to know
    how I can recall HTML form results on the next page (in a shopping cart) with a price based on the
    choices picked in the form. It sounds complicated...look at this example: Check out this page:
    http://www.plugcomputers.com/intelprobuild.php See how when the user goes through and picks all
    their computer parts a price at the bottom shows the system price based on their sel....
  20. Php Help Needed Including File In A Page.
    (2)
    i'm a noob in php programming, i can understand and modify php programs, but i dont know to
    write on my own. So please somebody who is well versed in php help me. My need is, I'm
    currently builiding a knowledge base website , i've my own design for the website, check here,
    http://laschatz.info/kzone/ Each page in the left hand site has a tree navigation of all the
    topics available. Since this information must be same in all the pages, presently I need to change
    all the pages after adding a new category. Could you please help me in such a way that I can ad....
  21. Help Php: How To Load String From Text File (solved)
    Loading string from text file when you click on your link (9)
    I learned the way to load other files with the code posted on this forum. Now i wanted to try
    something for my side menu. I am calling this a string, --> $tekst , maybe it's called
    something else i'm not sure Now let's say i have a file called details.txt In that file i
    would like to have something like this $detailsaboutphp1 = ("details details details 1");
    $detailsaboutphp2 = ("details details details and even more details 2"); How to make a code that
    loads those $strings on click of a mouse. When we tried to load external file we used this:
    ....
  22. Php And Disabling Html Tags
    how can i do this? (11)
    Hello everyone Im TRYING to make a forum and obviously for security i need to disable HTML tags
    being used in posts. i know how to use the str_replace() function but to be honest i think id have
    to do that for every single tag. I also trued using the html CODE stuff tag but i need to
    be able to use the new line tag to make a new line as all the posts are stored as HTML. if this isnt
    clear let me give an example: QUOTE NEW POST PAGE > user makes new post and posts it > PHP
    PROCCESSOR PAGE MAKES HTML FILE > NEW HTML FILE CONTAINING THE POST > user veiws ....
  23. Adapting Html Code Embed To Work On Phpnuke
    Help With This Html Code Pls (7)
    QUOTE how can get this html code to work on my phpnuke site? what tags would i
    have to enable in the $Allowable HTML part of my config.php file?? Edited topic title. Moved to
    Programming. ....
  24. Include File.php?id=something
    using the include() function (13)
    Well, I am making a full CMS system for my site, and want to make the index.php file to include the
    view.php?id=1 file. I tried with this code, but it didn't work: CODE This is the error
    I get: CODE Warning: main(view.php?id=1) : failed to open stream: Invalid argument in
    C:\server\xampp\htdocs\test\index.php on line 1 Warning: main() : Failed opening
    'view.php?id=1' for inclusion (include_path='.;C:\server\xampp\php\pear\') in
    C:\server\xampp\htdocs\test\index.php on line 1 So what can I do?....
  25. I Need Help With File Edit In Php
    with ftp (6)
    Currently i have CODE if($_POST =="" or $_POST =="" or $_POST =="" or $_POST =="" or
    !isset($_POST )){  print(' ');  print('FTP username ');  print('FTP
    password ');  print('FTP Host ');  print('FTP Root Directory ');
     print(' ');  print(' '); }else{ $ftp_server = $_POST ; $ftp_user = $_POST ;
    $ftp_pass = $_POST ; $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to
    $ftp_server please refresh and do not click retry"); // try to login if (@ftp_login($conn_id,
    $ftp_user, $ftp_pass)....
  26. File Uploading Issues
    (5)
    i have never tried to have files uploaded and i am still not able to do so. here is the codes that i
    am using right out of the php manual and it still isnt working. i have also listed the
    warnings/errors listed on the resulting page. my permissions are set to 777 also. i have a folder
    set up on my server as "uploads". i am however not sure if i have a default temp folder on my
    server. can anyone help me figure out what i am not doing correctly or what my next step is? this
    is the form that i am using: html Code: CODE        Choose a file to upload:     ....
  27. Error When Using file_put_contents()
    failed to call to undefined function (5)
    Hey all, I decided to write a script which writes some text to a file, but I have a problem when I
    execute the script, I get a fatal error: QUOTE(homepage) Fatal error : Call to undefined
    function: file_put_contents() in /home/cmatcme/public_html/afile.php on line 55 This is the
    code I'm using to write the file: $ipfnsdoc = "/home/cmatcme/public_html/afolder/afile.txt";
    if (!is_readable($ipfnsdoc)) { echo "File cannot be read"; $stopload = 1; } if
    (!is_writable($ipfnsdoc)) { echo " \nFile cannot be written to"; $stoploa....
  28. Script: Php Jukebox
    A one file script! (6)
    This scripts is so simple, you dont need to edit ANY of it! All you have to do is make a folder
    called 'songs' and put some audio files in it. Here is the whole page, I named it index.php
    and put it in a folder called 'music': CODE PHP jukebox ©2005 Craig lloyd.
    All rights reserved. Visit cragllo.com for more scripts --> /** * ©2005 Craig lloyd. All rights
    reserved. * * Mod Title:           Simple PHP Jukebox * Author:              Craig Lloyd * Author
    Email:        cragllo@cragllo.com * Author Homepage:     http://www.cragllo.com/ * Des....
  29. Getting List Of Directories And Files Using Php
    PHP Function for Directory and File List (6)
    is there a php function that lists the content of some folder.... example: /New folder new.txt
    left.gif download.zip dc.exe ....so is there..? /rolleyes.gif' border='0'
    style='vertical-align:middle' alt='rolleyes.gif' /> ....
  30. Pages In 1 File
    ?? (10)
    I know its possible to put many pages inside 1 file. But how? Lets say you have a guestbook with
    different pages for signing and viewing. How to make so those pages are in 1 file? /huh.gif"
    style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" />....

    1. Looking for file, checker, check, file, whith, html, html,
Similar
Php - Fetching Random Line From A Text File - and displaying it using AJAX/iframe
Weird Formatting: Embedding Php Into Html
Linux/ Apache /mod_rewrite Issue - Error when accessing a file
Html Form! - Using MySQL?!
Php Configuration File - "config.php"
Need Some Help In File Browser - listing all sub folders and files in them.
How Do I Get The Result To "stick" And Add Html Tags? - Help please?
Updating Php File Through A Web Form
Html Code Tester. Online Script
Html Site With Login - Is it possible?
Script To Translate Into Bbcode From Html Tags
Php And Flash Image Gallery - Need some help in creating or editing an xml file while viewing some o
No File Extension
File Upload - File upload
<?php ?> Unique Visitors Script - Flat file unique visitors script (no sessions)
<?php ?> Marking Up With Php - How to simply add HTML tags with PHP
[php]simple Flat File Text Manipulator - Example on how to use forms to write to files in PHP
Edit .txt File In Ftp Via Webpage - file on external ftp
Help With Moving Html Form Results To Shopping Cart?
Php Help Needed Including File In A Page.
Help Php: How To Load String From Text File (solved) - Loading string from text file when you click on your link
Php And Disabling Html Tags - how can i do this?
Adapting Html Code Embed To Work On Phpnuke - Help With This Html Code Pls
Include File.php?id=something - using the include() function
I Need Help With File Edit In Php - with ftp
File Uploading Issues
Error When Using file_put_contents() - failed to call to undefined function
Script: Php Jukebox - A one file script!
Getting List Of Directories And Files Using Php - PHP Function for Directory and File List
Pages In 1 File - ??

Searching Video's for file, checker, check, file, whith, html, html,
See Also,
advertisement


File Checker-how To Check File Whith Html Through Html?

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com