wolfas Posted July 11, 2006 Share Posted July 11, 2006 Hello, i have a problem in this script.the problem is that this form works then i use submit instead of image and with image this form doesn't work :-[ <?phpecho "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";if ($_POST['submit']){ echo $user.' '.$pass;}else{echo "<p><input type=\"text\" name=\"user\" size=5 maxlength=12 value=\"name\"></p>";echo "<p><input type=\"password\" name=\"pass\" size=7 maxlength=12 value=\"password\"></p>";echo "<p><input type=\"image\" src=\"image.jpg\" height=\"16\" width=\"24\" border=\"0\" ALT=\"hello\" name=\"submit\"></p>";echo "</form>";}?> Quote Link to comment https://forums.phpfreaks.com/topic/14266-form-that-doesnt-work-in-some-ways/ Share on other sites More sharing options...
Prismatic Posted July 11, 2006 Share Posted July 11, 2006 [code]<?phpif($_POST['_submit_check']){ echo $_POST['user'].' '.$_POST['pass'];}else{ echo "<form action='". $_SERVER['PHP_SELF'] ."' method='POST'> <p><input type='text' name='user' size='5' maxlength='12' value='name'></p> <p><input type='password' name='pass' size='7' maxlength='12' value='password'></p> <p><input type='image' src='image.jpg' height='16' width='24' border='0' ALT='hello' name='submit'></p> <input type='hidden' name='_submit_check' value='1'/> </form>";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14266-form-that-doesnt-work-in-some-ways/#findComment-56046 Share on other sites More sharing options...
kenrbnsn Posted July 11, 2006 Share Posted July 11, 2006 The problem occurs because when an image is used for a submit button, the x & y positions in that image are returned to your script. To see what is being returned, put this statement at the start of your script:[code]<?phpif (isset($_POST)) echo '<pre>' . print_r($_POST,true) . '</pre>';?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/14266-form-that-doesnt-work-in-some-ways/#findComment-56166 Share on other sites More sharing options...
Daniel0 Posted July 11, 2006 Share Posted July 11, 2006 If you still wan't to use an image as a button then change this line:[code]echo "<p><input type=\"image\" src=\"image.jpg\" height=\"16\" width=\"24\" border=\"0\" ALT=\"hello\" name=\"submit\"></p>";[/code] to this line:[code]echo "<p><button type='submit' style='border: 0px; padding: 0px;' name='submit' alt='hello'><img src='image.jpg' height='16' width='24' border='0'></button></p>";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14266-form-that-doesnt-work-in-some-ways/#findComment-56222 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.