newbie help...

Cannot figure this out:
[php]<?php
$home=getcwd();
function filestart($email,$fileinfo)
{
echo getcwd()."
";
chdir(“data”);
echo getcwd()."
";
if(!(file_exists($email))) {
$fptr = fopen($email,“x”) or die(“Unable to open file!1”);
fclose($fptr);
}
$ffptr = fopen($email,“a+”) or die(“Unable to open file!2”);
fwrite($ffptr,$fileinfo);
}
function getemail($email) {
?>

What is your email: <?php } // $email="[email protected]"; if (!($_POST['Submit'])) { filestart($email,"What the hell"); } else { getemail($email); }

[/php]

What part of that can’t you figure out?

See my comments

[php]<?php
//Sets the variable $home to the current working directory
$home=getcwd();
function filestart($email,$fileinfo)
{
// Displays the current working directory
echo getcwd()."
";
// Changes the directory to CWD/data
chdir(“data”);
// Displays the new Current working directory
echo getcwd()."
";
//checks to see if the user submitted email exists as a file
if(!(file_exists($email))) {
// If it doesn’t exists it creates it
$fptr = fopen($email,“x”) or die(“Unable to open file!1”);
fclose($fptr);
}
// Opens the file if it existed or the new file you created
$ffptr = fopen($email,“a+”) or die(“Unable to open file!2”);
//Writes some still to the file most like the “What the Hell” data
fwrite($ffptr,$fileinfo);
}

function getemail($email) {
?>
<-- draws a form with a text box for email and a submit button -->

What is your email: <?php } // $email="[email protected]"; //Calls one of the two functions above if (!($_POST['Submit'])) { filestart($email,"What the hell"); } else { getemail($email); }[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service