Am using XAMP 1.7.3 on Macbook pro osx 10.9 Firefox browser
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:
$txtfile="registration.txt";
$handle=fopen($txtfile,'a');
But I keep getting the this error message :
Warning: fopen(registration.txt) [function.fopen]: failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 30
Warning: fwrite() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 31
Warning: fwrite() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 32
Warning: fwrite() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 33
Warning: fwrite() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 34
Warning: fwrite() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 35
full code is :
<html>
<head>
<title>User Informations</title>
</head>
<body>
<form method="post" action="">
Name : <input type="text" name="name"/> <br>
Age : <input type="text" name="age"/> <br>
City : <input type="text" name="city"/> <br>
Password: <input type="password" name="pswrd1"/> <br>
Password: <input type="password" name="pswrd2"/> <br>
<input type="submit" name="submit" value"send"/>
<form/>
<?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>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 > 18";
}
else echo "city must be dubai";
}
else echo "password must identical";
echo "<br>";
}
?>
</body>
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
i changed the file option to read & 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 ...
so how could i fix this ? also am wondering if the rest of error messages related to the main problem ?
all in all, could someone tell me at least if there is a mistake in my code ?