Cannot INSERT data into mysql using php -
I'm trying two days to figure out this. I have literally copied from a tutorial and I still can not insert data into a table. Here is my code with the form
Customer type & lt; Font face = "wordana" & gt; & Lt; Choose name = "cut type" size = "1" & gt; & Lt; Options & gt; Non contract & lt; / Options & gt; & Lt; Options & gt; Contract & lt; / Options & gt; & Lt; / Select & gt; & Lt; / Font & gt; & Lt; Br> Contract Time & lt; Font face = "wordana" & gt; & Lt; Input type = "text" name = "contract hoard" value = "0" & gt; & Lt; / Font & gt; & Lt; Br> & Lt; Font face = "wordana" & gt; & Lt; Input type = "submit" name = "hasis" value = "add customer" & gt; & Lt; / Font & gt; & Lt; / Form & gt; & Lt; / Font & gt; & Lt; Font face = "wordana" size = "2" & gt; & Lt ;? Php if (isset ($ _ POST ['isis'])) {$ con = mysql_connect ("localhost", "root", "password"); If (! $ Con) {dead ("Can not connect:". Mysql_error ()); } Mysql_select_db ("averyit_net", $ con); $ Sql = "custom_profile (customer_name, customer type, contract_house) values ('$ _POST [company]', '$ _ POST [custType]', '$ _ POST [contracthouse]')" INSERT; Mysql_query ($ sql, $ con); Print_r ($ sql); Mysql_close ($ thief); }? & Gt; This is my PHPmyadmin server information:
Server: 127.0.0.1 through TCP / IP software: MySQL Software Version: 5.5.27 - MySQL Community Server ( GPL) Protocol version: 10 users: root @ localhost server charset: UTF-8 Unicode (UTF 8)
Please tell me why this does not work. When I run the site, it enters the information and when I press the submit button, it disappears, but it does not go into the table. No error messages are showing. Your SQL statement has improved slightly, It is stored in an array and make sure your post data is really set, otherwise it will put an empty value. Please always clear your input
in your manage_cust.php:
& lt ;? Php if (isset ($ _ POST ['hasis'])) {$ con = mysql_connect ("localhost", "root", "password"); If (! $ Con) {dead ("Can not connect:". Mysql_error ()); } Mysql_select_db ("averyit_net", $ con); $ Company = issuing ($ _ POST ['company'])? $ _ POST ['Company']: Nil; $ Custype = isset ($ _ POST ['custType'])? $ _ POST ['custType']: Nouel; $ Hour = release ($ _ POST ['contract horse'])? $ _ POST ['Assurances']: Nouel; Include $ Sql = "custom_profile (customer_name, customer type, contract_hors) values ('$ company', '$ ciestpe', '$ hours')"; Mysql_query ($ sql, $ con); Mysql_close ($ thief); }? & Gt;
Comments
Post a Comment