I am trying to access PHP's $_POST array from a template, using PHP within the template and have the expiration_date of the entry updated. The $_POST is empty, although the form is submitting to the same URL.
This is the EE template:
{exp:channel:form channel="auction" return="auction/new"}
<input name="title" type="text" />
<input name="auction_description" type="text" />
<input name="auction_price" type="text" />
<input type="submit" value="Submit" />
{/exp:channel:form}
This is the HTML of the Form:
<form id="publishForm" method="post" action="http://123.123.123.123/auction/new" enctype="multipart/form-data" >
<input type="hidden" name="RET" value="http://123.123.123.123/auction/new" />
<input type="hidden" name="URI" value="auction/new" />
<input type="hidden" name="return_url" value="auction/new" />
<input type="hidden" name="author_id" value="1" />
<input type="hidden" name="channel_id" value="1" />
<input type="hidden" name="entry_id" value="0" />
<input type="hidden" name="ACT" value="8" />
<input type="hidden" name="return" value="auction/new" />
<input type="hidden" name="site_id" value="1" />
<input name="title" type="text" />
<input name="auction_description" type="text" />
<input name="auction_price" type="text" />
<input type="submit" value="Submit" />
This is the PHP code:
<?php
if (!empty($_POST['title'])) {
ee()->db->update(
'exp_channel_titles',
array(
'expiration_date' => '123'
),
array(
'entry_date' => $_POST['entry_date']
)
);
}
?>
.htacess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
The PHP parse stage is set to Input and the template's name is the same as the channel's action.
Any help would be highly appreciated. I've been struggling with this for almost a week now.