I can submit input with type "submit" but once I changed it to "image" it doesn't submit.

Works with submit:

<FORM ACTION="balance.php" METHOD="POST" enctype="multipart/form-data">
    <input name="addBal" type="submit"/>
    </form>

Doesn't work with image:

<FORM ACTION="balance.php" METHOD="POST" enctype="multipart/form-data">
    <input name="addBal" src="pics/add.png" type="image"/>
    </form>

Output end (balance.php):

if(isset($_POST['addBal'])) {
    echo 'TESTER';
}

I've made a typo: but the problem still remains. Type submit works, and image doesn't

有帮助吗?

解决方案

You can try this example:

<button type="submit" name="addBal" style="padding: 0; border: none;"><img src="monkeydluffy.png" /></button>

It can serve the same purpose of submitting. As for additional information, you can check out this discussion regarding your concern.

Input Type image submit form value?

其他提示

Probably you're looking for type image:

<input name="addBal" type="image" src="pics/add.png" alt="Submit" />
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top