How To Insert Html Select Value As Text In Mysql Via Php June 26, 2023 Post a Comment I have this select field: ` City...TSolution 1: Are 775>Tbilisi, 776>Kutaisi static data in html? Simply you can create an array like$regions = array('775'=>'Tbilisi','776'=>'Kutaisi'); Copyand before processing form substitute values:$region = $regions[$_POST['region']]; CopySolution 2: Set up a switch statement with all the values listed and their corresponding names. The major advantage of this is that you have all possible "safe" values already listed, therefore if a user tries to use SQL injection, they won't be able to attack you because it will revert to your default case. However the disadvantage is that if there are lot of fields, you will have to list them all. I'm pretty sure there might be a way to hack the system, to get "innerHTML" property with the POST request, but I'm not sure.$region = $_POST["region"]; switch($region){ case"775": $insert = "Tbilisi"break; ...//more cases default: //if no case matches, do something here break; } CopySolution 3: I don't know if you still need this info, but: 1. first of all, why don't you use the select option like this? <optionvalue="Tbilisi">Tbilisi</option><optionvalue="Kutaisi">Kutaisi</option>CopyThen the Php will take the name directly. If for any reason, the option above is not possible, I would also suggest jQueryuse this (to post your value -as region name - to you php script):$var = $("#regioni option:selected" ).text(); $.post( "your-php-script.php", { region:$var } ); Copythis code above should be included in an event handler (onclick, onselect...) depending what you need. read more about jquery, you need it. Share Post a Comment for "How To Insert Html Select Value As Text In Mysql Via Php" Top Question Secure Way Of Passing Values Using Post Method I need to pass a few values using POST method form to anoth… Border Issue In Floating Div Further to the discussion in Floating div issue in IE i add… Red Border Still Appears On Inputs After Resetting An Html 5 Form Firefox I have an HTML 5 form! Great, I'm excited! I decide to … Tooltip(title Attribute) Is Getting Truncated Scenario: I am working on a product where i need to display… How To Hide And Show A Table-row (css-tables) I'm trying to hide and show a table row using css-table… SVG Animation And Firefox I'm struggle with SVG animation drawing, which is work … Dropdown Menu On Refresh Changes Javascript I have implemented a navbar uisng bootstrap 4,in which I ha… Flex-box Only Display As Many Items That Fit In A Container I want to only use CSS to make it so I have a container whi… How To Prevent Div From Getting Cut Of When Resizing Window? I have a div on the left side of the browser that shows fin… Flexbox Difficulties Aligning Icons To Bottom Of Container I'm having some difficulties with flexbox. As you can s… December 2024 (1) November 2024 (39) October 2024 (56) September 2024 (18) August 2024 (192) July 2024 (178) June 2024 (395) May 2024 (700) April 2024 (462) March 2024 (878) February 2024 (949) January 2024 (810) December 2023 (851) November 2023 (425) October 2023 (657) September 2023 (299) August 2023 (328) July 2023 (278) June 2023 (340) May 2023 (206) April 2023 (151) March 2023 (138) February 2023 (178) January 2023 (241) December 2022 (132) November 2022 (226) October 2022 (179) September 2022 (158) August 2022 (296) July 2022 (90) Menu Halaman Statis Beranda © 2022 - Html5 Developer