Jump to content

Why My Form Is Not Working?


Alicia

Recommended Posts

Hi,

 

I am trying to create a simple form with image buttons but why my php page can't capture the value of the image button clicked?

 

can somebody give me a hint about this.. thankyou

 

<form id="form1" name="form1" method="post" action="process.php">
  <tr>
  <td colspan="2"><input type="image" name="Submit" id="Submit" src="images/01.jpg" value="Mobile" /></td>
  <td>
    <input type="image" name="Submit" src="images/03.png" id="Submit" value="Hardware" /></td>
  <td> </td>
  <td> </td>
   </tr>
</form>

 

in my php file i put use this code.. it is very simple and straight forward but wonderng why nothing is printed.. Other elements in the form can be printed except the value of the submit image. =(

 

echo $_POST['Submit'];

Link to comment
Share on other sites

<input type="image" name="Submit" src="images/03.png" id="Submit" value="Hardware" />

Not Equal To

<input type="submit" name="Submit" id="Submit" value="Hardware" />

 

If you want to check whether the form has been submitted, you could use a hidden input field.

Link to comment
Share on other sites

i am not uploading any image so the form type is not what i need.. actually i have 2 image buttons for them to click..in my php file, i want to do conditional statement $_POST['Submit'] == a do this or b do that so hidden value wont work in this case since we need to perform an action based on the image button clicked\

 

any guru can advise

Link to comment
Share on other sites

The value attribute of an image being used as a submit button won't be submitted (well it will by some browsers, but those are not following the w3.org specification.)

 

To distinguish which image was clicked, that will work in all browsers, you must use different names for each one.

Link to comment
Share on other sites

print_r($_POST, 1) would show nothing...unless you put it inside the rest of the statement like you were asked to do.

 

Why not able to solve the issue is because you're not giving us any information. Copy and paste the command you were given. Show the output. It absolutely 100% will always print something. Show us that something.

Link to comment
Share on other sites

I managed to solve this one by using css button..

 

another new question if any guru can assist.

 

now I put this

<input type="hidden" name="checkboxes[]" value="<? echo $row['memo'] ?>" /><input type="hidden" name="checkboxes[]" value="<? echo $row['memo'] ?>" />

inisde a for loop

 

when I posted to the php file, it has error : Warning: Invalid argument supplied for foreach() in

when I use this :

foreach($_POST['checkbox'] as $copid){

 

The code works when I use it as checkbox but why it doesn't work anymore after I changed it to hidden value ? any idea??

Link to comment
Share on other sites

This will not work as stated sending images outputs X and Y cordinates

 

if(isset($_POST['submit'])) { //** Do Stuff **//
}

 

however this will because it includes the X & Y cordinates in the submit.

 


if(isset($_POST['submit_x') && isset($_POST['submit_y'])) { //**DO Stuff**//
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.