I am writing a php script which does the following:
- Accepts incoming POST data from an article editing page.
- Checks if the dropdown list on the previous page was set to "Create New Folder".
- If so it checks if something is in the textbox named foldercreate.
- Inserts this into the database if it is.
- If not it creates a Miscellaneous folder in the database and uses that in the insert.
The trouble is I keep getting a white screen when I hit the form submit button on the previous page. It shows savearticle.php in the address bar but nothing else. It won't even print out error messages. I must have rewritten this about three times now so forgive any logic errors in the code but it should be working as far as I can see. I just want to make sure it's working in its present form before going any further.
The echo statements throughout the code are something I found useful for debugging in the past but it doesn't display a single one.
In the functions.php include I am just using the database connection information as I use this across multiple pages without issue.
Any help would be appreciated as this is getting pretty frustrating.
<?php
echo "start of file";
include_once 'functions.php';
echo "after include";
$title = $_POST[ 'title' ];
$body = $_POST[ 'body' ];
$folderselect = $_POST[ 'folderselect' ];
$foldercreate = $_POST[ 'foldercreate' ];
$newfolderflag = 99;
echo "after variables";
if ($folderselect === "Create New Folder") {
$folder = $foldercreate;
$newfolderflag = 0;
} else if ($foldercreate == NULL && $folderselect === "Create New Folder"){
$folder = "misc";
echo "Nothing selected. Putting in Miscellaneous folder.\n\n";
$newfolderflag = 0;
} else {
$folder = $folderselect;
}
if ($newfolderflag === 0) {
$query = "INSERT INTO folder ('name') VALUES ('$folder');";
if (mysqli_query($db, $query) == TRUE) { echo "New folder created successfully!\n\n"};
}
echo "after if statements";
$query = "SELECT 'folderID' FROM folder WHERE name = $folder;";
$result = mysqli_query($db, $query);
$row = array();
$row = mysqli_fetch_array($result);
$folder = $row['0'];
$query = "INSERT INTO article ( title, body, folderID, userID ) VALUES ('$title', '$body', '$folder', '$user');";
if (mysqli_query($db, $query) === TRUE) {
echo "Article Saved!\r";
echo "<a href="write.php">Back</a>";
}
echo "after database stuff";
?>