wispas Posted November 19, 2010 Share Posted November 19, 2010 Hi, I have a form on my page. <form id="advanced_search" name="advanced_search" method="POST" action="<?php echo $PHP_SELF;?>"> </form> Form submits with a regular button <input type="submit" name="advSearch" id="advSearch" value="Search" /> And i have a detector to see where submit button has been clicked on my next page: if(isset($_POST['advSearch'])) { echo "Button was clicked"; } However, I wanted a custom button for better styling and control. So i replaced my regular button with this now which uses javascript to submit the form. <a class="button" href="javascript:document.advanced_search.submit()" name="advSearch" id="advSearch"><span>Search</span></a> Now the isset($_POST) is not working anymore. Can anyone help please?? Thanks! Link to comment https://forums.phpfreaks.com/topic/219184-if-isset-argument-from-submit-form-button/ Share on other sites More sharing options...
Pikachu2000 Posted November 19, 2010 Share Posted November 19, 2010 Add a hidden field and check for its value to determine if the form has been submitted. That's technically a better way to do it anyhow. <input type="hidden" name="submitted" value="yes"> if( isset($_POST['submitted']) && $_POST['submitted'] == 'yes' ) { Link to comment https://forums.phpfreaks.com/topic/219184-if-isset-argument-from-submit-form-button/#findComment-1136592 Share on other sites More sharing options...
wispas Posted November 19, 2010 Author Share Posted November 19, 2010 Works a treat.. Thanks so much! Link to comment https://forums.phpfreaks.com/topic/219184-if-isset-argument-from-submit-form-button/#findComment-1136597 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.