Page 1 of 1

Problem with $_POST vars

Posted: Mon Nov 27, 2006 11:05 am
by ubiko
Hi, I got this form code:

Code: Select all

<form method="post" action="modifica_cnota_url.php?id='.$_GET["id"].'" enctype="multipart/form-data">
   <input type="file" name="nueva_img_pres"><input type="image" src="images/disk-icon.gif" value="Save" name="actualiza_adj" style="border:0px;">
<input type="image" name="borra_adjunto" value="borra_adjunto" src="images/tut_email_icon_trash.gif" style="border:0px;">
</form>
In the same page I got this PHP in the header:

Code: Select all

if($_POST['actualiza_adj']=="Save")
{
actions.............
}

if($_POST['borra_adjunto']=="borra_adjunto")
{
actions.............
}
I catch the form name button and his value to make a concrete action if this form has been sent.
I have several of this forms in the page with a concrete action each one and it works fine.

The problem comes when I have test it in another server and it doesn't work at all. It never enter in the above condition.... someone has an idea? Maybe a php.ini configuration.

I've tried globals on the other server and nothing....

Some help will be wellcome


:lol:

Posted: Mon Nov 27, 2006 11:09 am
by RobertGonzalez
How are you checking if the form is posted?

Posted: Mon Nov 27, 2006 11:11 am
by volka
try

Code: Select all

echo '<pre>Debug: _POST='; var_export($P_POST); echo "</pre>\n";
if($_POST['actualiza_adj']=="Save")
{
	actions.............
}

if($_POST['borra_adjunto']=="borra_adjunto")
{
	actions.............
}
What does it print?

Posted: Mon Nov 27, 2006 11:14 am
by ubiko
It return that scary thing:
Debug: _POST=null

Posted: Mon Nov 27, 2006 11:16 am
by John Cartwright

Code: Select all

echo '<pre>Debug: _POST='; var_export($_POST); echo "</pre>\n";
Volka had a typo, please try this again.

Posted: Mon Nov 27, 2006 11:21 am
by ubiko
Debug: _POST=array (
'titulo' => 'hd',
'fecha_pub' => '2006-11-30',
'fecha_cad' => '2006-11-29',
'id_adj' => '3',
'adj_src' => 'nota_presenta_nota1_lost.jpg',
'actualiza_adj_x' => '4',
'actualiza_adj_y' => '13',
)

This sounds better. Maybe i have to check something like that $_POST["actualiza_adj_x"] to know if that submit button has been clicked.... [/img]

Posted: Mon Nov 27, 2006 11:26 am
by volka
Looks like you have an input/image as submit button and you're using IE. Mozilla does not append _x/_y but sends the value.
Are there multiple submit buttons in one form or do you check different forms?

Posted: Mon Nov 27, 2006 11:33 am
by ubiko
I have severeal forms within an input type image for save and an input type image to delete....
I want to know wich "input image has been clicked in the same form (save or delete)

Posted: Mon Nov 27, 2006 11:47 am
by ubiko
I 've found the problem, and that's internet Explorer don't return the value attribute of "input type image" while Firefox yes.
In the other server I was checking with IE and the other with FF and that the point.

I think I have to change my beatiful icons for "input type submit" buttons...

Posted: Mon Nov 27, 2006 11:59 am
by Burrito
ubiko wrote:I think I have to change my beatiful icons for "input type submit" buttons...
no, just change the way you're checking to see which has been clicked.

Posted: Mon Nov 27, 2006 12:16 pm
by ubiko
....how?

Posted: Mon Nov 27, 2006 12:18 pm
by Burrito
isset() is your friend here.

Posted: Mon Nov 27, 2006 12:20 pm
by ubiko
...and what's inside isset()?

Posted: Mon Nov 27, 2006 12:25 pm
by Burrito
basically you'll want to check if the array key is set which will be different for each browser.

Code: Select all

if(isset($_POST['actualiza_adj_x']) || isset($_POST['actualiza_adj']))
// do stuff