ksa Posted October 24, 2016 Share Posted October 24, 2016 Attached are my 3 files. You will have to create the database and tables first to test this. I'm using MySQL. the field names for the table are: Book_Id Book_Name Author Book_price The main form is updateinsertdata2.php. This file is the html form to work with. When you click on the 'edit' link (make sure there is data in the table first to see this link), the top of the form is filled in with data and an 'update' button appears When you click on the 'update' button the $_POST does not get set so my code does not get executed. Why? connecttodb.php indexupdateexp.php updateinsertdata2.php Quote Link to comment https://forums.phpfreaks.com/topic/302392-why-isnt-my-_post-variable-being-set/ Share on other sites More sharing options...
mac_gyver Posted October 24, 2016 Share Posted October 24, 2016 (edited) your $_POST data isn't the problem. your code is most likely being executed. why you are getting a symptom that makes it appear like your code isn't being executed is due to either php's output_buffering (hides output from your code and php errors if there is a header() redirect) and/or php's error reporting/display_errors (php errors are not being reported/displayed) settings that are set on your server. you should be getting an error like this - Notice: Undefined variable: GET in C:\xampp\htdocs\updateinsertdata2.php on line xx <----- the line where your UPDATE sql query statement is at you need to have the following set in the php.ini on your development system - error_reporting = E_ALL display_errors = ON output_buffering = OFF make sure these are set as shown, restart your web server to get any changes made to the php.ini to take effect, and confirm that the settings actually got changed by checking the values with a phpinfo() statement in a .php script. this will get your development system set up so that it will help you by showing any output from your code and from php errors. once you are getting that particular Notice: ... error, it should be easy to find and fix the problem in your code. next, you need to use prepared queries, with place-holders in the sql query statement for data values and use exceptions to handle database errors. this will actually simplify both your sql query and php program logic. unfortunately, the php mysqli extension is not the best choice. if you can, switch to use the php PDO extension. it is more consistent and easier to use than the mysqli extension. Edited October 24, 2016 by mac_gyver Quote Link to comment https://forums.phpfreaks.com/topic/302392-why-isnt-my-_post-variable-being-set/#findComment-1538543 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.