Ive researched the topic online and can’t find an answer on this question:
If I passed a record to a form while using a hyperlink and the GET method and now I want to make change to the data inside the form, can I update this form while using the POST method to the database and update the existing record?
I am fairly new in php and don’t know all the rules yet. To me it seems like if I already have an input field set to value=“echo $_GET[‘firstname’]” I won’t be able to update my form to mysql since I am using the POST method and think the form would automatically revert to the data I populated the form with. I;m saying this because when I click my sumit button the form reverts back to the data I first populated the form with???
Yes, I’d think you can. Your form gets populated with data passed into it via $GET which it will use as default values, but as long as you set the form method to POST, you then call whatever php updates your form. By the time your browser gets around to submitting the form using the button, it has no knowledge of how the default values arrived in the form.
If you’re having trouble with what it does when you click the submit button, post your code so someone can figure out what. Note that above, I’m not necessarily advocating changing field names for no apparent reason, just trying to make it clear.
As @megazoid said, it’s not good practice to pass the whole lot around as part of the URL. I am no security expert, but I would think it makes it very easy to stick any old data in there because the URL can be altered so easily.
My goodness I feel a bit ridiculous now after reading megazoid and your answer. Live and learn and get better lol. ok, so this bit of logic will solve a whole bunch of problem with sticky form and the echo of my updated database record. I think I will give this a shot and re-write my update code with this logic in mind and if I hit a brick wall I will come back and ask if anyone can verify my code. I find I learn a lot more if I try figuring the problem myself than be given the answer. thanks a bunch.