Results 1 to 5 of 5

Thread: creating comments on my server

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    creating comments on my server

    Hi, im creating a txt from my web.. but when i check it in my cpanel why Comments isn't create?

    this is the code.. when i test this from my localhost its working properly..
    whats wrong with this?

    PHP Code:
    <table width="100%" height="100%">
    <?php

            
    // filename

            
    $file "Comments.txt";

            
    // validate form 
            
            
    function form_validate () {
                    
                    if (
    sizeof($_POST) < 1) return false;
                    
                    foreach (
    $_POST as $name => $value) {
                            if (empty(
    $name) || !isset($name)) {
                                    return 
    false;
                            }            
                    }
                    return 
    true;
            }
            
            function 
    blank_replace ($str) {
                    return 
    str_replace (" ","|",$str);
            }
            
            function 
    stick_escape ($str) {
                    return 
    str_replace ("|"," ",$str);
            }


            if (
    form_validate()) {
                        
                    
    $fp fopen ($file,"at");
                    
    fwrite ($fp,uniqid(rand(),true)."\t".blank_replace($_POST['name'])."\t".blank_replace($_POST['comment'])."\n");
                    
    fclose ($fp);                        
            }

            if (!
    file_exists($file)) {
                    echo 
    "Here, no commments"//sorry my bad english
            
    } else {

                    
    $fp fopen ($file,"r");
            
                    while (
    $info fscanf ($fp,"%s\n%s\n%s\n\n")) {        
                            list (
    $id,$name,$comment) = $info;
    ?>

    <table border="1" width="47%">
      <tr>
        <td width="26%">Name : </td>
        <td width="74%"><?=stick_escape($name)?></td>
      </tr>
      <tr>
        <td width="26%">Comment:</td>
        <td width="74%"><?=stick_escape($comment)?></td>
      </tr>
    </table>
    <br>

    <?php        
                    
    }        
            }

    ?>


    <hr>

    <form action="index.php" method="post">
    Name :
    <br>
    <input name="name" type="text" size="30">
    <br>
    Comment :
    <br>
    <textarea cols="30" name="comment"> </textarea>
    <br>
    <input type="submit" value="Submit">
    </form>
    </table>

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: creating comments on my server

    what's it meant to do?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2002
    Location
    Philippines
    Posts
    877

    Re: creating comments on my server

    that is a simple shout box.. i want the data save in txt format "Comments.txt"

    when the user visited my site he will post the Name and Comments and if he press submit the data will record on comments.txt

    br,

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: creating comments on my server

    Does your host support file I/O operations?

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: creating comments on my server

    You should check the file handle directly after opening it.
    Also, the script should emit an error message if it can't open the file. If it doesn't, enable error reporting.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width