php - Insert DropDown Values to MYSQL -
This is my html form and php file which I want to include in my database by selecting the dropdown values in the database. Enter the selected value in the database and my data is being included in my database when I click on submit button twice
gt; & Lt; Br / & gt; & Lt; Div class = "label" & gt; Email & lt; / Div & gt; & Lt; Input type = "text" id = "email" name = "email" /> gt; & Lt; Br / & gt; & Lt; Div class = "label" & gt; Phone number & lt; / Div & gt; & Lt; Input type = "text" id = "phone" name = "phone" /> gt; & Lt; Br / & gt; & Lt; Div class = "label" & gt; Budget & lt; / Div & gt; & Lt; Select ID = "Budget" name = "budget" & gt; & Lt; Option value = "" & gt; Select & lt; / Options & gt; & Lt; Option value = "1" & gt; 0-100 & lt; / Options & gt; & Lt ;! - Value in the first option = "" - & gt; & Lt; Option value = "2" & gt; 100-200 & lt; / Options & gt; & Lt; Option value = "3" & gt; 200-300 & lt; / Options & gt; & Lt; / Select & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; Input type = "submit" onclick = "add ()" name = "submit" /> & Lt; Div id = "message" & gt; & Lt; / Div & gt; & Lt; / Form & gt;
insert.php
& lt ;? Php included ("config.php"); If (isset ($ _ POST ['submit'])) {$ name = $ _ POST ["name"]; $ Email = $ _ post ["email"]; $ Phone = $ _ post ["phone"]; $ Budget = $ _ post ["budget"]; $ Insert_query = "Enter the form (name, email, phone, budget) value ('$ name', '$ email', '$ phone', '$ budget')"; $ Thor = mysql_query ($ insert_query); }? & Gt;
Variables in the dropdown pass option value so that you can change the option value You want to enter the database
& lt; Id = "budget" name = "budget" & gt; & Lt; Option value = "" & gt; Select & lt; / Options & gt; & Lt; Option value = "0-100" & gt; 0-100 & lt; / Options & gt; & Lt ;! - Value in the first option = "" - & gt; & Lt; Option value = "100-200" & gt; 100-200 & lt; / Options & gt; & Lt; Option value = "200-300" & gt; 200-300 & lt; / Options & gt; & Lt; / Select & gt;
Comments
Post a Comment