Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form button image with value?

Status
Not open for further replies.

ro6er

Programmer
Joined
Jul 1, 2003
Messages
76
My first page has this:

<form action=&quot;test.php&quot; method=&quot;post&quot;>

<input type=&quot;submit&quot; name=&quot;name&quot; value=&quot;1&quot;>

<input type=&quot;image&quot; src=&quot; border=&quot;0&quot; name=&quot;name&quot; value=&quot;1&quot;>

</form>


The page it's post to is this:

<?php

@extract($_POST);

$name = stripslashes($name);


?>


<? print $name; ?>

I can get the <input type=&quot;submit&quot; name=&quot;name&quot; value=&quot;1&quot;>
to work fine but I can't get the image submit to work. This is probably something simple right?
 
And why do you need to pass the value of 1 through the IMAGE submit?? Just do it like this:
Code:
<form action=&quot;test.php&quot; method=&quot;post&quot;>
 <input type=&quot;hidden&quot; name=&quot;val&quot; value=1>
 <input type=&quot;image&quot; src=&quot;[URL unfurl="true"]http://www.herbs-direct-uk.co.uk/images/submit.gif&quot;;[/URL]
 border=&quot;0&quot; name=&quot;name&quot;>

</form>
and then in test.php script:
Code:
<?php
  if(isset($_POST['val'])) echo $_POST['val'];
?>

Or maybe you want to do something else then pass some value to php script. The other option is to make it as this:
Code:
<form action=&quot;test.php?val=1&quot; method=&quot;post&quot;>
 <input type=&quot;image&quot; src=&quot;[URL unfurl="true"]http://www.herbs-direct-uk.co.uk/images/submit.gif&quot;;[/URL]
 border=&quot;0&quot; name=&quot;name&quot;>
</form>
and you will also be able to access the variable called $val in your php script (this is the GET method) ;-)
 
Ok thanks. That did the trick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top