Problem with $_POST vars

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ubiko
Forum Newbie
Posts: 7
Joined: Mon Nov 27, 2006 10:54 am

Problem with $_POST vars

Post 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:
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

How are you checking if the form is posted?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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?
ubiko
Forum Newbie
Posts: 7
Joined: Mon Nov 27, 2006 10:54 am

Post by ubiko »

It return that scary thing:
Debug: _POST=null
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

echo '<pre>Debug: _POST='; var_export($_POST); echo "</pre>\n";
Volka had a typo, please try this again.
ubiko
Forum Newbie
Posts: 7
Joined: Mon Nov 27, 2006 10:54 am

Post 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]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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?
ubiko
Forum Newbie
Posts: 7
Joined: Mon Nov 27, 2006 10:54 am

Post 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)
ubiko
Forum Newbie
Posts: 7
Joined: Mon Nov 27, 2006 10:54 am

Post 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...
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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.
ubiko
Forum Newbie
Posts: 7
Joined: Mon Nov 27, 2006 10:54 am

Post by ubiko »

....how?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

isset() is your friend here.
ubiko
Forum Newbie
Posts: 7
Joined: Mon Nov 27, 2006 10:54 am

Post by ubiko »

...and what's inside isset()?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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
Post Reply