Home > database >  How do you validate a html unicode in php
How do you validate a html unicode in php

Time:11-16

I am passing values from HTML form to a php file for processing

   $to_do = $_POST['action'];

Then i can say

    <?php
        if( $to_do == "delete") {
           echo "i will delete for you";
           }
      ?>

Difficulty i am having is when the HTML value is unicode &#10008 for a delete symbol. instead of the value "delete". In php i cannot tell how to test it.

    <?php
        if( $to_do == "&#10008") {
           echo "i will delete for you";
           }
      ?>

is not working. Any one to help me out?

CodePudding user response:

How are you sending this value to begin with - via something like <input type="submit" value="✘">?

In that case, I would recommend you switch to a button element - that can have a separate submission value and display text. So you can keep sending delete, and show to the user at the same time.

<button type="submit" value="delete"></button>

More details on the button element can be found in the MDN, https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button

  • Related