title: PHP fopen () function failed to open and permission denied
body: <p>Am using XAMP 1.7.3
  on Macbook pro osx 10.9
  Firefox browser</p>
  
  <p>Well basically i am trying to write a code asking the user to enter some information and then store the information in a .txt file using the: </p>
  
  <pre><code> $txtfile="registration.txt";
   $handle=fopen($txtfile,'a');
  </code></pre>
  
  <p>But I keep getting the this error message :</p>
  
  <blockquote>
    <p>Warning: fopen(registration.txt) [function.fopen]: failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 30</p>
    
    <p>Warning: fwrite() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 31</p>
    
    <p>Warning: fwrite() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 32</p>
    
    <p>Warning: fwrite() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 33</p>
    
    <p>Warning: fwrite() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 34</p>
    
    <p>Warning: fwrite() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 35</p>
  </blockquote>
  
  <p>full code is :</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;User Informations&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;form method="post" action=""&gt;
      Name    : &lt;input type="text" name="name"/&gt; &lt;br&gt;
      Age     : &lt;input type="text" name="age"/&gt; &lt;br&gt;
      City    : &lt;input type="text" name="city"/&gt; &lt;br&gt;
      Password: &lt;input type="password" name="pswrd1"/&gt; &lt;br&gt;
      Password: &lt;input type="password" name="pswrd2"/&gt; &lt;br&gt;
      &lt;input type="submit" name="submit" value"send"/&gt;
      &lt;form/&gt;
      &lt;?php
  
      if(isset($_POST['submit']))
      {
  
          $name=$_POST["name"];
          $age=$_POST["age"];
          $city=$_POST["city"];
          $pswrd1=$_POST["pswrd1"];
          $pswrd2=$_POST["pswrd2"];
  
          if($pswrd1 == $pswrd2){
              if($city==dubai){
                  if($age&gt;18){
                      $txtfile="registration.txt";
                      $handle=fopen($txtfile,'a');
                      fwrite($handle, $name);
                      fwrite($handle, $age);
                      fwrite($handle, $city);
                      fwrite($handle, $pswrd1);
                      fwrite($handle,$pswrd2);                    
                  }
                  else echo "age must be &gt; 18";
              }
              else echo "city must be dubai";
          }
          else echo "password must identical";
          echo "&lt;br&gt;";
  
  
  
      }
  
      ?&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>first i understood the first error message, failure to access / create the .txt file, and as i searched in this website, several ppl had the same problem, some the suggested a permission problem with the main file, and since every time i try to update the php file i get asked to enter my admin password, so i assumed the XAMP main file also protected</p>
  
  <p>i changed the file option to read &amp; write by all users, and all the folders within the main XAMP folder. but still i get asked for the password to save any changes in the php file am writing this code in, and thus i guess am still getting the same :
  fopen(registration.txt) [function.fopen]: failed to open stream: Permission denied in ... </p>
  
  <p>so how could i fix this ? 
  also am wondering if the rest of error messages related to the main problem ?</p>
  
  <p>all in all, could someone tell me at least if there is a mistake in my code ?</p>