Harry Harry - 6 months ago 11
PHP Question

Form submit button isn't working?

I've had this issue before, so I usually always use "

<input type='submit' ... >
" however I wish to have a bin image as the button as opposed to text (obviously to create a delete button). In order for me to do this I need to use the button tag, however the PHP code isn't working for it.

HTML:

<form action='#' method='POST'>
<button type='submit' name='form-wallpostdelete'>Delete</button>
</form>


PHP:

$delete_post = @$_POST['form-wallpostdelete']; //Form variable

if($delete_post) {
echo "Deleted";
}
?>


Really simple, when I use "input type='submit' name='form-wallpostdelete' value='Delete'>" it works, and the message is echoed back, however when I use the button the page simply refreshes.

Answer
Use isset() method for checking  
<form action='#' method='POST'>
      <button type='submit' name='form-wallpostdelete'>Delete</button>
    </form>
    <?php 
    $delete_post = @$_POST['form-wallpostdelete']; //Form variable

    if(isset($delete_post)) {
        echo "Deleted";
    }
    ?>