Adsa Posted September 17, 2008 Share Posted September 17, 2008 I am trying to create a rollover image for a submit button but when i use the input type as image the values I am sending in the form are not getting sent. Is this how the image process works? I want to keep it as simple as possible Any help would be great. echo "<form method=\"post\" action=\"register1.php\" alt=\"Register\"><p><br>"; echo "<b>Name : </b><br><input name=\"full_name\" type=\"text\" id=\"full_name\"></p>"; echo "<p><b>Email : </b><br><input name=\"email\" type=\"text\" id=\"email\"></p>"; echo "<p><b>Password : </b><br><input name=\"pass1\" type=\"password\" id=\"pass1\"></p>"; echo "<p><b>Retype Password : </b><br><input name=\"pass2\" type=\"password\" id=\"pass2\"></p>"; echo "<p><b>Email Opt out? : </b><br><input name=\"opt_out\" type=\"radio\" id=\"opt_out\" value=\"No\" checked>No"; echo "<input name=\"opt_out\" type=\"radio\" id=\"opt_out\" value=\"Yes\">Yes</p>"; echo "<p><b>Code : </b><br><input name=\"user_code\" type=\"text\" size=\"11\"><br>"; echo "<img src=\"key/pngimg.php\" align=\"middle\"> </p>"; echo "<p><input type=\"image\" name=\"submit\" value=\"submit\" src=\"img/buttons/register_1.png\" onmouseover=\"this.src = 'img/buttons/register_0.png'\" onmouseout=\"this.src = 'img/buttons/register_1.png'\"></p></form>"; Quote Link to comment https://forums.phpfreaks.com/topic/124584-input-as-image/ Share on other sites More sharing options...
AndyB Posted September 17, 2008 Share Posted September 17, 2008 I suspect that your problem lies with register1.php. Maybe you want to post some of that. Quote Link to comment https://forums.phpfreaks.com/topic/124584-input-as-image/#findComment-643495 Share on other sites More sharing options...
Adsa Posted September 17, 2008 Author Share Posted September 17, 2008 If i replace this echo "<p><input type=\"image\" name=\"submit\" value=\"submit\" src=\"img/buttons/register_1.png\" onmouseover=\"this.src = 'img/buttons/register_0.png'\" onmouseout=\"this.src = 'img/buttons/register_1.png'\"></p></form>"; With echo "<p><input type=\"submit\" name=\"submit\" value=\"submit\"></p></form>"; It works fine. Changing it to submit rather than an image it returns the form values. Quote Link to comment https://forums.phpfreaks.com/topic/124584-input-as-image/#findComment-643498 Share on other sites More sharing options...
PFMaBiSmAd Posted September 17, 2008 Share Posted September 17, 2008 Browsers don't send the value="..." for type="image" (well some of them do, but they are not required to.) The specification only requires that the x,y coordinates where the image was clicked be send to the server. From the php manual HTML/FAQ - I'm trying to use an <input type="image"> tag, but the $foo.x and $foo.y variables aren't available. $_GET['foo.x'] isn't existing either. Where are they? When submitting a form, it is possible to use an image instead of the standard submit button with a tag like: <input type="image" src="image.gif" name="foo" /> When the user clicks somewhere on the image, the accompanying form will be transmitted to the server with two additional variables: foo.x and foo.y. Because foo.x and foo.y would make invalid variable names in PHP, they are automatically converted to foo_x and foo_y. That is, the periods are replaced with underscores. So your form would set $_POST['submit_x'] and $_POST['submit_y'] Quote Link to comment https://forums.phpfreaks.com/topic/124584-input-as-image/#findComment-643651 Share on other sites More sharing options...
CroNiX Posted September 17, 2008 Share Posted September 17, 2008 you can use a javascript onClick event for the input image and tell that to submit the form. Quote Link to comment https://forums.phpfreaks.com/topic/124584-input-as-image/#findComment-643788 Share on other sites More sharing options...
TheFilmGod Posted September 17, 2008 Share Posted September 17, 2008 A bit of research on the good old friend google would have told you that you can use <button></button> to create a fancy image button that still submits normally. And yes browsers are required to send all information through the form since this is a button! Quote Link to comment https://forums.phpfreaks.com/topic/124584-input-as-image/#findComment-644193 Share on other sites More sharing options...
PFMaBiSmAd Posted September 18, 2008 Share Posted September 18, 2008 Unfortunately, a <button></button> as a submit button has the following issue (just confirmed for myself) - Important: Be careful when using the button element in a form. In a form the different browsers will submit different values. Internet Explorer will submit the text between the <button> and </button> tags, while other browsers will send the content of the value attribute. The solution of course is to use the name_x or name_y from the type="image" or use a hidden field with the name and value that you want. Quote Link to comment https://forums.phpfreaks.com/topic/124584-input-as-image/#findComment-644327 Share on other sites More sharing options...
TheFilmGod Posted September 18, 2008 Share Posted September 18, 2008 Unfortunately, a <button></button> as a submit button has the following issue (just confirmed for myself) - Important: Be careful when using the button element in a form. In a form the different browsers will submit different values. Internet Explorer will submit the text between the <button> and </button> tags, while other browsers will send the content of the value attribute. The solution of course is to use the name_x or name_y from the type="image" or use a hidden field with the name and value that you want. Huh? He wants a simple submit button that is styled completely. If the form is valid, there should be no problem. I have used <button> for more than 2 years and never had problems w/ it. This includes safari, FF, opera, and IE6+. You might be getting confused about <button type="submit" name="submit" value="submit"> Submit </button> Quote Link to comment https://forums.phpfreaks.com/topic/124584-input-as-image/#findComment-645213 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.