damdempsel Posted April 15, 2010 Share Posted April 15, 2010 I am trying to create a file when someone registers on my site. The only way I can find how to do this is using the fopen() code. When I run it I get an access denied error. I talked with my host and they allow use of it. They also allow chmod() so I switched it to 777 just to see. It still wouldn't work. Here is the code I used: <form action="index.php" method="post"> <input type="text" name="username" value="Username"> <input type="submit" name="submit" value="Submit"> </form> <?php $username = strtolower($_POST['username']); $submit = $_POST['submit']; $newpage = "/users/".$username.".html"; if ($submit) { if (ctype_alnum($username)) { fopen($newpage, "w"); fwrite($newpage, $username); header("location: ".$newpage); } else { echo "Please do not use symbols in your username."; } } ?> (Parts of the code were taken out to make it shorter.) Is there something wrong with this code? Is there another way to make a file when someone registers? Link to comment https://forums.phpfreaks.com/topic/198595-fopen-access-denied/ Share on other sites More sharing options...
ChemicalBliss Posted April 15, 2010 Share Posted April 15, 2010 Basically change this: /users/ to this: ./users/ A forward slash on its own basically means start from the root of the drive. Use a dot before it to state the current directory. -cb- Link to comment https://forums.phpfreaks.com/topic/198595-fopen-access-denied/#findComment-1042119 Share on other sites More sharing options...
damdempsel Posted April 15, 2010 Author Share Posted April 15, 2010 Wow. Now I feel kind of stupid. It works fine now. Thanks. Link to comment https://forums.phpfreaks.com/topic/198595-fopen-access-denied/#findComment-1042122 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.