View Full Version : if(isset($_POST wont works in Joomla with jumi

02-12-2010, 04:21 PM
Hi to all!

I have a working php page integrated in a Jumi module, this page contains a form with an hidden field:

<form method='post' action='index.php?option=com_content&view=article&id=10?start=$start' enctype='multipart/form-data'><input type='submit' name='prov' value='Publish' /><input type='hidden' name='id1' value='$id'/><input type='hidden' name='start1' value='$start'/><input type='hidden' name='prov' value='form'/></form>

so with this statement:

$_POST['id1'] = $id1;
$_POST['start1'] = $start1;
$redirect_page = "index.php?option=com_content&view=article&id=2&number=$id1";
header('location: ' . $redirect_page);

It understand that the form is sent and it should go to another page, but the problem is that $_POST['id1'] and $_POST['start1'] don't get values, why? Out of joomla all works correvtly...

02-12-2010, 04:39 PM
No clue how joomla works.
You can't just add onto the _POST array, its always extracted on the first load. With this, you can simply retrieve from $_GET since you're passing the same information over. If you want to send post without a form, you'll need to look into something like curl to force post headers instead of get headers.

02-12-2010, 05:15 PM
Thnx but i would like to mantain this code if possible.
I've tried with print_r($_POST); and i get:

Array ( [prov2] => form [id1] => [start1] => [layout] => default [view] => article )

no POST variables...


Solved in this way:

if(isset($_POST['prov'])){ // si viene dal form, si processano i dati e si effettua il redirect
// si processano tutti i dati del form
$_GET['id1'] = $id1;
$_GET['start1'] = $start1;

$query2 = "UPDATE table SET number= '1' WHERE id = '".$_POST['id1']."' " ;
$result2 = mysql_query($query2) or die ("ERROR!" . mysql_error(). 'Query: '.$query2);
$redirect_page = "index.php?option=com_content&view=article&id=10?start=".$_POST['start1']."";
header('location: ' . $redirect_page); };

Don't ask me why it works, i don't know, absolutly!!! :)