Jump to content

fopen() Access denied.


damdempsel

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.