Monday 15 September 2014

php - Best Way to Post Data from Large Forms & Hold Data in Inputs after Errors -


This is a "best practice" / "most efficient" question I have a large form (20+ fields) Post the form in the large MySQL table.

No I can not break the form and no, I can not break the table (to measure its measurement); Administrator is used by the sales representative Also, I do not want to use javascript.

I know I can do this: HTML

  & lt; Form action = "etcphp" method = "post" & gt; & Lt; Input type = "text" name = "value" value = "" & gt; & Lt; Input type = "text" name = "arm" value = "" & gt; & Lt; Input type = "text" name = "back" value = "" & gt; & Lt; Input type = "text" name = "chest" value = "" & gt; & Lt; Input type = "text" name = "foot" value = "" & gt; & Lt; Submit button & gt;   

PHP

  & lt;? $ _POST ['neck']; $ _POST ['back']; $ _POST ['Hands']; $ _POST ['chest']; $ _POST ['Leg']; $ PostMeasurements = "Include the value (etc, etc., etc.) WHERE etc. = 'etc.'; Query ($ post-maker);? & Gt;    P> But is this a fast way? Instead of declaring each term, just run a loop, which takes all the data into the table and is included in the table even if the data is in the same order as the table column or if the input Name table is similar to column names, so I'm fine; I'm just tired, all these $ _POST The second question: What is the best way to capture this data in the case of an error? As it stands now, I have $ _SESSION (one session variable for each input ), Then get back to the form page when there is an error with an error message. Input values ​​like variable $ _SESSION.  

thanks,

if field as the name of the field Exact name e fields and nothing else

  // If there is a $ _POST form, it is also very unsafe because there is no prevention of injection. $ Sql ​​= "Include in the table" ("Implode (", ", array_keys ($ _ POST)") "" value ('". Implode ("','", array_values ​​($ _ POST)). "')";    

No comments:

Post a Comment