Frage

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

War es hilfreich?

Lösung

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?

Andere Tipps

Probably you're looking for type image:

<input name="addBal" type="image" src="pics/add.png" alt="Submit" />
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top