Jump to content

IF isset Argument from submit form button...


wispas

Recommended Posts

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!

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' ) {

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.