UPDATE: I added the action "index.php" to the form and it worked fine. Noob mistake but working now.
I've been wrestling with this for a few days and I must be missing something simple because I had it working before.
I have the following (simplified) code to upload a file and save some data, but when I submit the form, the page just reloads. This is a snippet of a bigger chunk of code, but everything else works just fine. I suspect it's something to do with the POST. Can anyone see where I'm going wrong?
$node = 'pubs';
// if url contains ?action=add&node=pubs
if ( $_GET['action'] == 'add' && $_GET['node'] == $node ) {
echo '<h2>Add New</h2>
<form action="" method="POST" enctype="multipart/form-data">
<label for="file">File</label>
<input type="file" name="file" />
// some other form fields
<input type="submit" name="add_new" value="Add It" />
<input type="hidden" name="node" value="'.$node.'" />
</form>';
// if submit button was pressed for this node (pubs)
} elseif ( isset($_POST['add_new']) && $_POST['node'] == $node ) {
echo 'Success!';
// some file and mysqli functions
}