Forum Moderators: coopster

Message Too Old, No Replies

enter key wouldnt work on <input type="image" .

Please help with enter key and <input type="image"...

         

wildrat

10:22 pm on Apr 26, 2008 (gmt 0)

10+ Year Member



Ok, I've been searching for 2 days now, how to make the enter key work when you use a login form with image type, here is form code:


<form action="index.php" method="post" id="loginform">
<fieldset>
<span class="label-u">Username:</span>
<input type="text" class="text-inp-u" name="username" value="" />
<span class="label-p">Password:</span>
<input type="password" class="text-inp-p" name="password"value="" />
<input type="image" src="images/okconfirm.jpg" class="button" id="submit" name="submit" />
<span><a href="#">Lost?</a> - <a href="register.php">Register</a></span>
</fieldset>
</form>

and this right here is the php post code:


<?php
if($_POST){
print_r($_POST);
}
if($_POST['submit_x']) {
echo "IMAGE BUTTON SET";
$username = $_POST['username'];
$password = $_POST['password'];

echo $username;
echo "<br />";
echo $password;
echo "<br />";
if ($username = "val" && $password == "pass") {
echo "successful login";
}
else {
echo "incorrect login";
}
}
else {
echo "IMAGE BUTTON NOT SET";
}
?>

i put the


if($_POST){
print_r($_POST);
}

at the top of the code, i found it out on some forums, but it didnt really help me :/ if anyone can help, please do, any suggestions/help is appreciated, thanks :)

cameraman

12:20 am on Apr 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, wildrat!

The print_r is just for diagnostics.
This here:
if($_POST['submit_x']) {

You don't have a form element by that name, instead you'd want:
if(isset($_POST['submit'])) {

since that's what your submit's name is.
And finally, you might want to try a button element instead:
<button style="background: url(images/okconfirm.jpg);" name="submit"...