Jump to content

creating a file with php - getting an error


knight47

Recommended Posts

I have no idea why this is giving the die() error, everything seems to be fine, can anyone spot any errors:

 

<?php

$name = htmlspecialchars($_POST['name']);
$msg = htmlspecialchars($_POST['msg']);
$clean_name = stripslashes($name);
$clean_msg = stripslashes($msg);
$cleaner_name = rtrim($clean_name);


$card = '<HTML CODE IS HERE>';

$link = "$cleaner_name" . ".htm";

if ($_POST['Submit'] && !empty($cleaner_name) && !file_exists($link))
{
  $create = fopen($file, 'w') or die("Hm... There seems to be an error!");
    fwrite($create, $card);
    fclose($create);
echo '<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.site.com/cards/' . $link  . '">';
}
else 
{
echo "Sorry, there seems to be a few problems, either 1, you left the Name field empty, if so, click back in your browser button, or that $cleaner_name has already been submitted, please visit <a href=\"http://www.site/cards/" . $file . ">www.site.com/cards/" . $file . "</a> to view the already existing card, thanks!";
}
?>

 

I keep getting this: "Hm... There seems to be an error!", which is supposed to be the error message if something goes wrong, but I have no idea what is wrong.

 

The folder is chmod to 777, and the php file is chmod to 755.

 

Thanks

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.