Sooo... I figured it out! Here is what I changed in case anyone has the same issue (would be an odd one):
<?php
$date = $_POST['date'];
$title = $_POST['title'];
$underscore = "_";
$dir = "";
if(!isset($_POST['dir'])) $_POST['dir']="";
switch($_POST['dir']) {
case "Site1": $dir = "path/to/site1"; break;
case "Site2": $dir = "path/to/site2"; break;
case "Site3": $dir = "path/to/site3"; break;
}
$myfile = fopen("$dir/$date$underscore$title.md", 'w');
if ($_SERVER['REQUEST_METHOD'] == "POST"){
$myfile or die("Can't open file for writing.");
fwrite($myfile, $_POST['textfield']);
fclose($myfile);
echo "Content saved. ";
echo "Your file: <b>" ;
echo $date;
echo $underscore;
echo $title . ".md</b> ";
echo "was successfully created to the website: <b>";
echo $_POST['dir'];
echo "</b>";
}
// Print the form
?>
I am surprised it worked because I have no idea what the hell I Was doing it just seemed logical so I did that.
The funny thing is my original idea worked, elseif all over the place looked extremely ugly though so I decided to use a switch statement since they are so clean and purdddy. I have yet to figure out the $underscore issue... But for the most part it is more secure now! :}