My next question is.

Is it possible to right an hmtl page or update an exsisting html page on there server were as before i would just update the database.

Thanks

    Certainly, you'd just write the HTML into a file instead of into a database. There's nothing in this code that stops you from doing anything you want with the submitted HTML or stops you from getting it from wherever you've got it.

      How do i go about creating the html page and saving or over-writing an existing page?
      It's somethimg i have never had to do.

      thanks
      Paul

        I think you could use fopen and fwrite in this case to overwrite the file's contents:

        <?php
        // select file
        $file = 'YourFileName.php';
        
        // select info to update file with as variable
        $string = $updated_html_file; 
        
        // If file exists and is writable
        if (is_writable($file)){
        
        // Open $file in write mode or exit
        if (!$handle = fopen($file, 'w')){
        echo 'Cannot open file ('.$file.').';
        exit;
        }
        
        // Write $string to our opened file or exit
        if (fwrite($handle, $string) === FALSE){
        echo 'Cannot write to file ('.$file.').';
        exit;
        }
        
        echo 'Success. The file, '.$file.', was appended with '.$string.'.';
        // close file handle
        fclose($handle);
        }
        
        else {
        echo 'The file '.$file.' is not writable.';
        }
        ?>

          Paul, make sure you open the file in 'w' mode (overwrite) rather than 'a' (apend) to completely overwrite the file with the new contents. I edited the code above....

          :- )

            Thanks.

            If the file does not exsist will it be created?

              [man]fopen[/man]

              Table 1. A list of possible modes for fopen() using mode
              mode Description
              'w' Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.

                Something is wrong somewhere. The files is created if it does not exsist but if the file does exsist then it adds to the contents of the fileπŸ™

                Can you see where i am going wrong:

                $file = "../../jcb/".$_POST['arTitle'].".htm"; 
                // select info to update file with as variable 
                $string = $updated_html_file;  
                // If file does not exist create and make writeable if (!is_writable($file)){ $handle = fopen($file, 'w+'); if (fwrite($handle, $string) === FALSE){ echo 'Cannot write to file ('.$file.').'; exit; } echo 'Success. The file, '.$file.', was created.'; // close file handle fclose($handle); }else{ $handle = fopen($file, 'w'); if (fwrite($handle, $string) === FALSE){ echo 'Cannot write to file ('.$file.').'; exit; } echo 'Success. The file, '.$file.', was appended.'; // close file handle fclose($handle); }

                Thanks

                  You will need file functions in php. These should get you started and sorted out:

                  quick to do tut.

                  [MAN]fopen[/MAN]
                  [MAN]fwrite[/MAN]
                  [MAN]file_exists[/MAN]
                  [MAN]is_writable[/MAN]

                    Paul Ferrie wrote:
                    // If file does not exist create and make writeable
                    if (!is_writable($file)){ 
                    	// do stuff
                    } 
                    

                    I think you mean to do this:

                    // If file does not exist...
                    if (!file_exists($file)){ 
                    	// do stuff
                    } 
                    
                      Write a Reply...