简体   繁体   中英

Save HTML form drop down option value attribute as HTML instead of special character (& instead of &)

I have a input form which has a select field. In the options you have a value attribute which I have a special character included. This is the code:

<option id="Applicant_Industry" value="Engineering &amp; Manufacturing | Food &amp; Snacks">Food &amp; Snacks</option>

When is stores to the database using PHP and mySQLi it saves it as its special character of &.

I was wondering if there is a way to allow PHP to save the HTML value instead of the special character? (eg & amp;)

I hope that makes sense!

Thanks!

You can't/shouldn't really, I suggest using the php function htmlspecialchars_decode()

Like this you can store the HTML in a safer way and decode it when echoing the data wherever you need it, and if you really have to save it use the function before inserting it. Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM