submit via picture?!

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
User avatar
SomeOne
Forum Commoner
Posts: 27
Joined: Tue Jul 25, 2006 2:06 am

submit via picture?!

Post by SomeOne »

i have the code like

Code: Select all

<form method="post" action="dodajSliko.php">
<input type="image" name="slikaNova" src="./pic1.jpg" height='100'value="./pic1.jpg"/>
<input type="image" name="slikaNova" src="./pic2.jpg" height='100'value="./pic2.jpg"/>
<input type="image" name="slikaNova" src="./pic3.jpg" height='100'value="./pic3.jpg"/>
<input type="image" name="slikaNova" src="./pic4.jpg" height='100'value="./pic4.jpg"/>
<form>
this pictures are alsow "submit" button...that means when you click on an image it processes the form and it work in mozilla, though on IE dosent..
I heard that this type of submission is not allowed or something, cos IE dosend send the value...
or something...
can anyone help me?
i really dont want to make extra hyperlih for each image to proceed....
:(
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

They are all named the same. Try changing their names.
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Post by Rovas »

If you want to submit the form when the user clicks a picture put the following Javascript code if you send them to the same page :

Code: Select all

<input type='image' name='pic1' id='pic1' onclick="document.form[0].submit()" height='100'value="./pic1.jpg"/>

Code: Select all

And on the page you use

Code: Select all

if (!empty($_GET['pic'])) {/*your code*/ }
User avatar
SomeOne
Forum Commoner
Posts: 27
Joined: Tue Jul 25, 2006 2:06 am

Post by SomeOne »

Everah wrote:They are all named the same. Try changing their names.
i dont think this is an issue, becous you can click only on one image at a time...
somebody say tat IE dosent send value of the value taht is set but sends the xy coordinates in pixels depending on position of clikc on the picture 8O
brendandonhue
Forum Commoner
Posts: 71
Joined: Mon Sep 25, 2006 3:21 pm

Post by brendandonhue »

Yes, it's not just IE. Browsers send the coordinates of where the user clicked the image.
User avatar
churt
Forum Commoner
Posts: 39
Joined: Wed Oct 04, 2006 9:59 am

I did this one time.

Post by churt »

I would do this instead.

Code: Select all

<form method="post" action="dodajSliko.php">
   <input type="image" name="slikaNova1" src="./pic1.jpg" height='100'value="./pic1.jpg"/>
   <input type="image" name="slikaNova2" src="./pic2.jpg" height='100'value="./pic2.jpg"/>
   <input type="image" name="slikaNova3" src="./pic3.jpg" height='100'value="./pic3.jpg"/>
   <input type="image" name="slikaNova4" src="./pic4.jpg" height='100'value="./pic4.jpg"/>
<form>
Use this code to detect which image was selected.

Code: Select all

foreach($_POST as $key => $value){
    if ($key=='slikaNova1_x') $slikaNova1='whatever';
    if ($key=='slikaNova2_x') $slikaNova2='whatever';
    if ($key=='slikaNova3_x') $slikaNova3='whatever';
    if ($key=='slikaNova4_x') $slikaNova4='whatever';
}
brendandonhue
Forum Commoner
Posts: 71
Joined: Mon Sep 25, 2006 3:21 pm

Post by brendandonhue »

You would probably want to add some validation to that, as it would allow a user to submit more than 1 of the image fields to your script.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

From what i remember is that IE appends _x and _y to the input name... Thus check if $_POST['slikaNova1'] or $_POST['slikaNova1_x'] exists...
Post Reply