Create page with form submission

Hey, I am currently programming a small script for my website which submits form information into a brand new page, into a directory created in the users name; if it doesn’t exist, it will create it. The information entered is supposed to travel to a “thank you” message which would also display a link to the created page. I have done something like this before, but it’s been a few years and my coding is a bit rusty. I had thought this bit of coding would work, but I receive an error upon submission. Any help is highly appreciated. Thanks.

Here is my form code:

[code]
Name:

Title:

Words:


[/code]

submit.php
[php] <?
if (isset($_POST[‘submit’])) {
$ttle = $_POST[‘title’];
$pstr = $_POST[‘name’];
$wrds = $_POST[‘words’];

// Store in or create directory
if(!file_exists($pstr))
{
mkdir($pstr);
}

// Create file
$fileName = dirname(FILE)."/$pstr/$ttle.html";
$fh = fopen($fileName, ‘w’) or die(“can’t open file”);
$str = "

test posting $ttle - written by $pstr
the words:
$wrds ";

fwrite($fh, $str);
fclose($fh);
// End create file

echo “Congradualations!

The file has been created.
Go to it by clicking <a href=”$pstr/$ttle.html">here.";
die();
}
?>[/php]

What is the error?

[php] <?
if ( strtolower( $_SERVER[‘REQUEST_METHOD’] ) == ‘post’) {
$ttle = $_POST[‘title’];
$pstr = $_POST[‘name’];
$wrds = $_POST[‘words’];

// Store in or create directory
if (! file_exists($pstr)) {
    mkdir($pstr);
}

// Create file
$fileName = dirname(__FILE__) . "/$pstr/$ttle.html";
$fh = fopen($fileName, 'w') or die("can\'t open file");
$str = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
test posting $ttle - written by $pstr
the words:
$wrds ";
fwrite($fh, $str);
fclose($fh);
// End create file

echo "Congratulations!<br />

The file has been created.
Go to it by clicking <a href="$pstr/$ttle.html">here.";
die();
}

[/php]

[member=72272]astonecipher[/member] ,

the strtolower here if ( strtolower( $_SERVER[‘REQUEST_METHOD’] ) == ‘post’) is completely useless and unnecessary.

Using if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) will work no matter if you do

or

Sponsor our Newsletter | Privacy Policy | Terms of Service