Jump to content

[SOLVED] input image problem


Goose87

Recommended Posts

Dear all,

 

I have a problem with a login script I am improving.  At the moment I am using a type='submit' button with CSS styling, but I want to change this and add an image.  I found on the internet that you can have type='image', but I can't get the button to submit.  It just loads up the action='login.php'.

 

The code I am using is:

 


<form method='post' action='login.php' name='auto_login'>
<input type='text' size='20' maxlength='20' name='username' class='textfield2' value='username'>
 
<input type='password' size='20' maxlength='20' name='password' class='textfield2' value='password'>
 
<input type="image" src="images/login_button.jpg" value="Submit" alt="Submit" name="top_submit" />
</form>

 

Then when I want to see if the button is pressed I have:

 


if(isset($_POST['top_submit'])){

echo "BUTTON PRESSED";

}

 

but the text never appears. 

 

Does anyone have any ideas?  As I am pretty stuck on this :(

 

Thanks in advance to everyone who helps me.

Link to comment
https://forums.phpfreaks.com/topic/164513-solved-input-image-problem/
Share on other sites

The problem you're having is one I've experienced before, the submit button seems to sometimes pass itself into post and sometimes not. Try adding:

 

<input type="hidden" name="formsubmit" value="login" />

 

Then at the top of login.php add:

 

<?php
if (isset($_POST['formsubmit']) && ($_POST['formsubmit'] == 'login')) {
    echo 'Button Pressed!';
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.