hahaitwork Posted October 30, 2012 Share Posted October 30, 2012 Any idea what could be wrong ? I do not get any errors but also, nothing in my database. Will answer tomorrow morning if anyone have answered -Thanks <html> <head> <title>update database</title> </head> <body> <form method="post" action="insertken.php"> ID: <input type="text" name="id" size="50" /> <br /> Name: <input type="text" name="name" size="50" /> <br /> Last Name <input type="text" name="description" size="50" /> <br /> price <input type="text" name="price" size="50" /> <br /> sla <input type="text" name="sla" size="50" /> <br /> quantity <input type="text" name="quantity" size="50" /> <br /> fix <input type="text" name="fix" size="50" /> <br /> <input type="submit" value="Update" /> </form> </body> </html> <?php $id = $_POST['id']; $name = $_POST['name']; $description = $_POST['description']; $price = $_POST['price']; $sla = $_POST['sla']; $quantity = $_POST['quantity']; $fix = $_POST['fix']; mysql_connect("localhost:3306","root","") or die ('ERROR: ' . mysql_error()); mysql_select_db ("my_db"); $query="INSERT INTO products (id, name, description, price, sla, quantity, fix) VALUES ('".$id."','".$name."','".$description."','".$price."','".$sla."','".$quantity."','".$fix."')"; ?> <form method="get" action="form.php"> <button type="submit">Continue</button> </form> Quote Link to comment https://forums.phpfreaks.com/topic/270082-submit-form/ Share on other sites More sharing options...
OOP Posted October 30, 2012 Share Posted October 30, 2012 (edited) You need to execute the query against your database using the mysql_query($query). You are not doing anything in your code and that is why your information is not getting inserted in the database. One more thing, the form method should be "post" instead of "get" Edited October 30, 2012 by OOP Quote Link to comment https://forums.phpfreaks.com/topic/270082-submit-form/#findComment-1388783 Share on other sites More sharing options...
White_Lily Posted October 30, 2012 Share Posted October 30, 2012 1) to keep consistency use an input type instead of a button for "continue". 2) escape some of those $_POST values. 3) don't post connection details on here 4) use error_reporting in a php.ini file. e.g: display_errors = on error_reporting = -1 Quote Link to comment https://forums.phpfreaks.com/topic/270082-submit-form/#findComment-1388784 Share on other sites More sharing options...
hahaitwork Posted October 30, 2012 Author Share Posted October 30, 2012 You need to execute the query against your database using the mysql_query($query). You are not doing anything in your code and that is why your information is not getting inserted in the database. One more thing, the form method should be "post" instead of "get" Sounds like I followed a pretty good tutorial >.< Quote Link to comment https://forums.phpfreaks.com/topic/270082-submit-form/#findComment-1388816 Share on other sites More sharing options...
Barand Posted October 30, 2012 Share Posted October 30, 2012 One more thing, the form method should be "post" instead of "get" Why? Quote Link to comment https://forums.phpfreaks.com/topic/270082-submit-form/#findComment-1388822 Share on other sites More sharing options...
OOP Posted October 31, 2012 Share Posted October 31, 2012 Why? Barand, because he is using the $_POST super global array in his script and not the $_GET Quote Link to comment https://forums.phpfreaks.com/topic/270082-submit-form/#findComment-1388947 Share on other sites More sharing options...
Barand Posted October 31, 2012 Share Posted October 31, 2012 The form that calls that scipt has a POST method <form method="post" action="insertken.php"> The form with the GET is merely a submit button to return to the form <form method="get" action="form.php"> <button type="submit">Continue</button> </form> Quote Link to comment https://forums.phpfreaks.com/topic/270082-submit-form/#findComment-1388958 Share on other sites More sharing options...
hahaitwork Posted October 31, 2012 Author Share Posted October 31, 2012 The form that calls that scipt has a POST method The form with the GET is merely a submit button to return to the form Followed another tutorial, this problem is solved now - thx. Quote Link to comment https://forums.phpfreaks.com/topic/270082-submit-form/#findComment-1388979 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.