Help with HTML FORM Syntax when using an image as the submit button in PHP SCRIPT

hi everyone.

i have two question regarding the correct HTML form SYNTAX for an image submit button for my PHP script.

QUESTION ONE:

i have a script that allows members of a site to send 'set saved messages ’ to other members. all they need to do is to press onto an icon

( its a email icon) and the ‘set saved message’ is sent.

the problem is that i dont know how to access this message once it is saved. sorry if my explanation is not very clear. it might be easier if i show u.



// THIS IS THE SAVED MESSAGE PLACED INTO A VARIABLE  

$MESSAGE =  "this is my saved messaged"; 


// start of the If condition to receive the sent message. 

	if(isset($_POST['image']))
	 
	//Start of  conditional  that test whether the form was submitted .	
	{
		  
			require_once ('db_fns.php'); // Connect to the db.
	
		  //process the text-input field

	   if(!empty($_POST['savedmessageidd'])) {
	    $savedmessage =   mysqli_real_escape_string($dbc, trim( $_POST['savedmessageidd']));
	
	 echo "this is the saved message  $savedmessage "; 
	  
	  }
	    		
	 
	  
	  //process the hidden filed text
	  if(!empty($_POST['savedmessageid'])) {
	    $savedmessageid =   mysqli_real_escape_string($dbc, trim( $_POST['savedmessageid']));
	
	  echo "this is the saved message id    $savedmessageid "; 
	  
	  }


	
	}//End of conditioanal that test whether the form was submitted .
		
		

//START OF THE FORM 


<form action= "  "      method="post" name="form" >


<input  type="image"  name="savedmessage" src="pics/icons/iconemail4.jpg" 
   width="30" height="30" alt="aupair from   "  value="image"       /> Send Saved Email </a>
    
    
    <input type="hidden" name="message "    value=" <?php echo $MESSAGE ?>" />
    
    <input type="hidden" name="savedmessageid"    value="17" />
    
    



what i attempted to do above is to send two seperate pieces of data to the server i.e;

  1. the $MESSAGE
  2. THE NUMBER 17

i am able to retreive this information. the problem i have however is how to access that information via the IF condition i.e

if(isset($_POST[‘image’]))

i understand that normallly  ( had i usd a submit button rather than the image, ) the if condition would have been; 

  if(isset($_POST['submit']))

but now that i am using an image, what should the if test be? i tried using the

if(isset($_POST[‘image’]))

but it does not work . please advise where i am going wrong.

ALSO, did i use the correct method to send the information. you will note that i used two seperate hidden filed imput to send the seperate information. should i instead have sent it via a

value=“message”

within the

<input type=“image” name=“savedmessage” src=“pics/icons/iconemail4.jpg”
width=“30” height=“30” alt="aupair from " value=“image” /> Send Saved Email </a>

i.e

<input type=“image” name=“savedmessage” src=“pics/icons/iconemail4.jpg”
width=“30” height=“30” alt="aupair from " <?php echo $MESSAGE ?> /> Send Saved Email </a>

i tried to send a value this way but it did not work, hence my resorting to using two seperate hidden filed imputs types .

QUESTION TWO

you would have noted that after the

<input type=“image” name=“savedmessage” /> Send Saved Email </a>

i had a text “Send Saved Email”

how do i do it so that if the mouse scroll over both the image or the text “send saved email” that the form is submitted.

i am not sure of the best way to achieve this.

thank you for your kind assistance.

warm regards

Andreea

Q1.

Name/value pairs from the form inputs are sent to the processing script. So you need to check for the existence of the image button name in your IF statement, and preferably also check that it also has the correct value.

Q2

you could put an onmouseover event handler on the <a> that runs a function that first validates all the form data and if all the form data is valid use the .submit() method on the form to submit it.