I am losing functionality when I change from an image to a simple button. This is the code when it is an image and it submits:
$form= "
<form method='post' action='/login.php'>
<b>Name:</b><br><input type='text' name='name'
size='19' class='login'><br><b>Password:</b><br><input
type='password' name='password' size='19' class=
'login'><br>
<img src='/layout/blank.gif' height='6' width='1'
alt='blank'><br>
<input type='hidden' name='redir' value='$redir'>
<input type='image' src='/layout/loginword.gif' name=
'action' value='Go' style='vertical-align: middle;'
title='Login'> (<a href='/lostdetails.php' class=
'menu'>Lost Details?</a>)
</form>";
When edited to display a button instead of an image as below I lose the functionality:
$form= "
<form method='post' action='/login.php'>
<b>Name:</b><br><input type='text' name='name'
size='19' class='login'><br><b>Password:</b><br><input
type='password' name='password' size='19' class=
'login'><br>
<img src='/layout/blank.gif' height='6' width='1'
alt='blank'><br>
<input type='hidden' name='redir' value='$redir'>
<input type='button' name=
'action' value='Go' style='vertical-align: middle;'
title='Login'> (<a href='/lostdetails.php' class=
'menu'>Lost Details?</a>)
</form>";
CodePudding user response:
This is occuring because input type="image"
has the same functionality of a submit
button, while input type="button"
does not have any implicit functionality. (It is just a dumb clickable button)
You need to change it to input type="submit"
CodePudding user response:
you should use type="submit"
and if you want to use the button, you should use the button tag
with type="submit"
CodePudding user response:
Don't use type="button"
in the submitting input! Try to use type="submit"
in that "Go" field.
That's because the first attribute value prompt to the browser that the button is literally a normal object which doesn't have nothing to do with that form. Maybe you can use it as a link, or a Javascript event caller ... but not as the submitting action.
So the new code will be:
<form method='post' action='/login.php'>
<b>Name:</b><br><input type='text' name='name'
size='19' class='login'><br><b>Password:</b><br><input
type='password' name='password' size='19' class=
'login'><br>
<img src='/layout/blank.gif' height='6' width='1'
alt='blank'><br>
<input type='hidden' name='redir' value='$redir'>
<input type='submit' name=
'action' value='Go' style='vertical-align: middle;'
title='Login'> (<a href='/lostdetails.php' class=
'menu'>Lost Details?</a>)
</form>
Obviously you can put it in you PHP variable, your choice. If you want to learn more about HTML buttons, here you can see the W3Schools documentation about it.
Andrea