Goose87 Posted July 2, 2009 Share Posted July 2, 2009 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 More sharing options...
iSE Posted July 2, 2009 Share Posted July 2, 2009 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!'; } ?> Link to comment https://forums.phpfreaks.com/topic/164513-solved-input-image-problem/#findComment-867729 Share on other sites More sharing options...
Goose87 Posted July 2, 2009 Author Share Posted July 2, 2009 Brilliant, that works Thanks a lot for helping me with that I can now release my new login script! Link to comment https://forums.phpfreaks.com/topic/164513-solved-input-image-problem/#findComment-867740 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.