Results 1 to 2 of 2

Thread: Error Reading/Writing

  1. #1

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Error Reading/Writing

    PHP Code:
    <html>
        <h3>Testing Site</h3>
        <form method = "POST" action = "<?php echo $_SERVER['PHP_SELF'];?>">
        <input type = "hidden" name = "send" value = "1">
        <p>UserName<input type = "text" name = "UserName"/></p>
        <p>Password<input type = "text" name = "Password"/></p>
        <input type="submit" value ="Login" />
        </form>
    <body background="http://users.pandora.be/creeping_death/Babes/Anna%20Kournikova%2002.jpg">
    </body>
    <?php
        
    If($_POST['send']=="1"){
             
    $filename "UnP.txt";
             
    $UserName $_POST['UserName'];
             
    $Password $_POST['Password'];
                  
    $handle fopen($filename,"r") or die("Err1");
                  
    $contents = @fread($handle,filesize($filename));
                  
    fclose($handle);
                              
    $Str strpos($contents,$UserName." ".$Password);
                                If(
    $Str===False){
                                  
    $MakeUser True;
                                }
                        If(
    $MakeUser True){
                            
    $handle fopen($filename,"w") or die("Err2");
                            
    $contents $contents.":$UserName $Password)";
                            
    fclose($handle);
                            echo 
    "Making Username";
                            }Else{
                                Echo 
    "Logged in!";
                        }
                            }
    ?>
    </html>
    Somethings going wrong in these lines:
    PHP Code:
                        If($MakeUser True){
                            
    $handle fopen($filename,"w") or die("Err2");
                            
    $contents $contents.":$UserName $Password)";
                            
    fclose($handle);
                            echo 
    "Making Username";
                            }Else{
                                Echo 
    "Logged in!";
                        } 
    Because its saying Making Username, but not entering the information (or erroring)..

  2. #2
    Addicted Member BIOSTALL's Avatar
    Join Date
    Apr 2005
    Location
    Northampton, UK
    Posts
    180

    Re: Error Reading/Writing

    You're forgetting to actually write to the file:

    @fwrite($handle, $contents) or die("Err3");

    Also, remember to make sure you CHMOD permission setting are set to at least 766.

    Hope that helps,

    BIOSTALL
    Last edited by BIOSTALL; Jul 22nd, 2005 at 05:54 AM.

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